Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add mirrored parameter to the create/update functions #40

Merged
merged 1 commit into from
Dec 12, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions src/controllers/entries.ts
Original file line number Diff line number Diff line change
Expand Up @@ -148,6 +148,7 @@ export default {
meta: body.meta,
recursion: body.recursion,
hidden: body.hidden,
mirrored: body.mirrored,
data: body.data,
unversionedData: body.unversionedData,
links: body.links,
Expand All @@ -174,6 +175,7 @@ export default {
mode: body.mode,
type: body.type,
hidden: body.hidden,
mirrored: body.mirrored,
revId: body.revId,
lockToken: body.lockToken,
skipSyncLinks: body.skipSyncLinks,
Expand Down
8 changes: 8 additions & 0 deletions src/db/models/entry/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -146,6 +146,7 @@ class Entry extends Model {
innerMeta = null,
unversionedData,
hidden = false,
mirrored = false,
recursion,
requestedBy,
data,
Expand Down Expand Up @@ -173,6 +174,7 @@ class Entry extends Model {
meta,
links,
hidden,
mirrored,
recursion,
createdBy,
requestedBy,
Expand Down Expand Up @@ -208,6 +210,7 @@ class Entry extends Model {
unversionedData,
permissionsMode,
initialPermissions,
mirrored,
});

if (!isValid) {
Expand Down Expand Up @@ -341,6 +344,7 @@ class Entry extends Model {
isDeleted,
deletedAt,
hidden,
mirrored,
})
.returning('*');

Expand Down Expand Up @@ -452,6 +456,7 @@ class Entry extends Model {
isDeleted,
deletedAt,
hidden,
mirrored,
})
.returning('*');

Expand Down Expand Up @@ -539,6 +544,7 @@ class Entry extends Model {
key,
meta,
hidden = false,
mirrored = false,
recursion,
requestedBy,
data,
Expand All @@ -561,6 +567,7 @@ class Entry extends Model {
meta,
links,
hidden,
mirrored,
recursion,
permissionsMode,
initialPermissions,
Expand All @@ -581,6 +588,7 @@ class Entry extends Model {
key,
meta,
hidden,
mirrored,
recursion,
data,
unversionedData,
Expand Down
3 changes: 3 additions & 0 deletions src/db/models/entry/scheme.ts
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,9 @@ export const validateCreateEntry = compileSchema({
initialPermissions: {
type: 'object',
},
mirrored: {
type: 'boolean',
},
},
});

Expand Down
6 changes: 6 additions & 0 deletions src/services/entry.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@ export default class EntryService {
meta,
recursion,
hidden,
mirrored,
data,
unversionedData,
links,
Expand All @@ -46,6 +47,7 @@ export default class EntryService {
type,
links,
hidden,
mirrored,
unversionedData,
meta,
data,
Expand All @@ -67,6 +69,7 @@ export default class EntryService {
meta,
recursion,
hidden,
mirrored,
requestedBy: user,
data,
unversionedData,
Expand All @@ -91,6 +94,7 @@ export default class EntryService {
meta,
recursion,
hidden,
mirrored,
data,
unversionedData,
links,
Expand All @@ -107,6 +111,7 @@ export default class EntryService {
type,
links,
hidden,
mirrored,
unversionedData,
meta,
data,
Expand Down Expand Up @@ -137,6 +142,7 @@ export default class EntryService {
meta,
recursion,
hidden,
mirrored,
requestedBy,
data,
unversionedData: unversionedData,
Expand Down
6 changes: 6 additions & 0 deletions src/services/entry/actions/create-in-workbook.ts
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,9 @@ export const validateCreateEntryInWorkbook = makeSchemaValidator({
hidden: {
type: 'boolean',
},
mirrored: {
type: 'boolean',
},
meta: {
type: ['object', 'null'],
patternProperties: AJV_PATTERN_KEYS_NOT_OBJECT,
Expand Down Expand Up @@ -73,6 +76,7 @@ export type CreateEntryInWorkbookData = {
type?: EntryColumns['type'];
links?: SyncLinks;
hidden?: EntryColumns['hidden'];
mirrored?: EntryColumns['mirrored'];
unversionedData?: EntryColumns['unversionedData'];
meta?: RevisionColumns['meta'];
data?: RevisionColumns['data'];
Expand All @@ -88,6 +92,7 @@ export async function createEntryInWorkbook(
type = '',
links,
hidden,
mirrored,
unversionedData,
meta,
data,
Expand Down Expand Up @@ -140,6 +145,7 @@ export async function createEntryInWorkbook(
updatedBy: createdBy,
deletedAt: null,
hidden,
mirrored,
});

await Revision.query(trx).insert({
Expand Down
6 changes: 6 additions & 0 deletions src/services/entry/actions/update-entry.ts
Original file line number Diff line number Diff line change
Expand Up @@ -84,6 +84,7 @@ type UpdateEntryData = {
type?: EntryColumns['type'];
unversionedData?: EntryColumns['unversionedData'];
hidden?: EntryColumns['hidden'];
mirrored?: EntryColumns['mirrored'];
meta?: RevisionColumns['meta'];
data?: RevisionColumns['data'];
revId?: RevisionColumns['revId'];
Expand All @@ -106,6 +107,7 @@ export async function updateEntry(ctx: CTX, updateData: UpdateEntryData) {
mode = 'save',
type,
hidden,
mirrored,
revId,
lockToken,
skipSyncLinks,
Expand All @@ -119,6 +121,7 @@ export async function updateEntry(ctx: CTX, updateData: UpdateEntryData) {
mode,
type,
hidden,
mirrored,
revId,
lockToken,
skipSyncLinks,
Expand Down Expand Up @@ -215,11 +218,14 @@ export async function updateEntry(ctx: CTX, updateData: UpdateEntryData) {
const revId = revision.revId;

const hiddenNext = typeof hidden === 'undefined' ? entry.hidden : hidden;
const mirroredNext =
typeof mirrored === 'undefined' ? entry.mirrored : mirrored;

const patch: Partial<EntryColumns> = {
savedId: revId,
updatedBy: updatedBy,
hidden: hiddenNext,
mirrored: mirroredNext,
};

if (type) {
Expand Down
1 change: 1 addition & 0 deletions src/types/models/entries.ts
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,7 @@ export interface CreationEntryConfig extends BasicRequestParams {
verbose?: any;
trxOverride?: any;
useLegacyLogin?: boolean;
mirrored?: boolean;
}
export interface PrivateCreationEntryConfig extends CreationEntryConfig {
masterToken?: any;
Expand Down
1 change: 1 addition & 0 deletions src/types/models/tables-columns.ts
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,7 @@ export interface EntryColumns {
isDeleted: boolean;
deletedAt: string | null;
hidden: boolean;
mirrored: boolean;
entryId: string;
savedId: string;
publishedId: string | null;
Expand Down
1 change: 1 addition & 0 deletions src/types/services.types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ export interface CreateEntry extends StdServiceParams {
key?: any;
meta?: any;
hidden?: any;
mirrored?: boolean;
recursion?: any;
createdBy?: any;
data?: any;
Expand Down
Loading