lucid-extension-sdk
Advanced tools
Comparing version 0.0.227 to 0.0.228
@@ -5,3 +5,3 @@ import { UpstreamPatchType } from '../core/data/datasource/upstreampatchtype'; | ||
import { FieldConstraintType } from '../core/data/serializedfield/serializedfielddefinition'; | ||
import { SerializedFields } from '../core/data/serializedfield/serializedfields'; | ||
import { SerializedFields, SerializedLucidDictionary } from '../core/data/serializedfield/serializedfields'; | ||
import { SerializedLabelOverrides } from '../core/data/serializedfield/serializedschema'; | ||
@@ -55,2 +55,3 @@ import { JsonSerializable } from '../core/jsonserializable'; | ||
itemsDeleted?: string[] | undefined; | ||
errors?: Map<string, SerializedLucidDictionary> | undefined; | ||
constructor( | ||
@@ -63,7 +64,8 @@ /** | ||
/** Items to remove from the collection, based on the same primary key algorithm. */ | ||
itemsDeleted?: string[] | undefined); | ||
itemsDeleted?: string[] | undefined, errors?: Map<string, SerializedLucidDictionary> | undefined); | ||
} | ||
export declare class ItemsPatchExhaustive { | ||
items: Map<string, SerializedFields>; | ||
constructor(items: Map<string, SerializedFields>); | ||
errors?: Map<string, SerializedLucidDictionary> | undefined; | ||
constructor(items: Map<string, SerializedFields>, errors?: Map<string, SerializedLucidDictionary> | undefined); | ||
} | ||
@@ -78,2 +80,4 @@ export type ItemsPatch = { | ||
itemsDeleted?: string[]; | ||
/** Errors found while patching the items */ | ||
errors?: Map<string, SerializedLucidDictionary>; | ||
} | ItemsPatchInexhaustive | ItemsPatchExhaustive; | ||
@@ -83,4 +87,6 @@ export type SerializedItemsPatch = { | ||
'itemsDeleted': string[]; | ||
'errors'?: Record<string, SerializedLucidDictionary>; | ||
} | { | ||
'exhaustiveItems': Record<string, SerializedFields>; | ||
'errors'?: Record<string, SerializedLucidDictionary>; | ||
}; | ||
@@ -110,2 +116,26 @@ export declare function serializeItemsPatch(patch: ItemsPatch): SerializedItemsPatch; | ||
export declare function serializeCollectionPatch(patch: CollectionPatch): SerializedCollectionPatch; | ||
/** | ||
* For the moment, when the upstream Google Sheet is changed in such a way that the schema has changed, we simply | ||
* stop updates from happening. We do need to alert the user that this has happened, though. This is a utility function | ||
* for creating the appropriate entry in the errors map so that the user can be alerted that updates have stopped | ||
* and what they need to do to fix it. | ||
* | ||
* The eventual, proposed fix is to allow schemas to have version numbers so that changes to the schema from Google | ||
* can simply be folded in to the on-document copies of the data and all following edits. | ||
* | ||
* @param oldPrimaryKey The primary key stored in the data sync service and which currently is used to interpret | ||
* patches. | ||
* @param newPrimaryKey The primary key as it has been changed in the real Google Sheets. | ||
* @returns The error map entry which alerts the document that this problem has happened. | ||
*/ | ||
export declare function schemaOutOfSyncStatus(oldPrimaryKey: string[], newPrimaryKey: string[]): [string, SerializedLucidDictionary]; | ||
/** | ||
* For the moment, when the upstream Google Sheet is changed in such a way that the schema has changed, we simply | ||
* stop updates from happening. We do need to alert the user that this has happened, though. We also need to know when | ||
* the updates are happening properly so we can clear the error once the user has resolved the problem. Since the | ||
* only way to delete errors is to overwrite them, we simply overwrite the error to be OK on every successful | ||
* import. | ||
* @returns The error map entry which alerts the document that this problem has been resolved. | ||
*/ | ||
export declare function schemaOKStatus(): [string, SerializedLucidDictionary]; | ||
export {}; |
"use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
exports.serializeCollectionPatch = exports.serializeFieldDefinitionForApi = exports.serializeItemsPatch = exports.ItemsPatchExhaustive = exports.ItemsPatchInexhaustive = void 0; | ||
exports.schemaOKStatus = exports.schemaOutOfSyncStatus = exports.serializeCollectionPatch = exports.serializeFieldDefinitionForApi = exports.serializeItemsPatch = exports.ItemsPatchExhaustive = exports.ItemsPatchInexhaustive = void 0; | ||
const fieldtypedefinition_1 = require("../core/data/fieldtypedefinition/fieldtypedefinition"); | ||
const object_1 = require("../core/object"); | ||
const collectionerrortypes_1 = require("../data/collectionerrortypes"); | ||
class ItemsPatchInexhaustive { | ||
@@ -14,5 +15,6 @@ constructor( | ||
/** Items to remove from the collection, based on the same primary key algorithm. */ | ||
itemsDeleted) { | ||
itemsDeleted, errors) { | ||
this.items = items; | ||
this.itemsDeleted = itemsDeleted; | ||
this.errors = errors; | ||
} | ||
@@ -22,17 +24,23 @@ } | ||
class ItemsPatchExhaustive { | ||
constructor(items) { | ||
constructor(items, errors) { | ||
this.items = items; | ||
this.errors = errors; | ||
} | ||
} | ||
exports.ItemsPatchExhaustive = ItemsPatchExhaustive; | ||
function serializeErrors(errors) { | ||
if (!errors) { | ||
return undefined; | ||
} | ||
const serializedErrors = {}; | ||
errors.forEach((dictionary, key) => (serializedErrors[key] = dictionary)); | ||
return { 'errors': serializedErrors }; | ||
} | ||
function serializeItemsPatch(patch) { | ||
var _a; | ||
if (patch instanceof ItemsPatchExhaustive) { | ||
return { 'exhaustiveItems': (0, object_1.fromEntries)(patch.items.entries()) }; | ||
return Object.assign({ 'exhaustiveItems': (0, object_1.fromEntries)(patch.items.entries()) }, serializeErrors(patch.errors)); | ||
} | ||
else { | ||
return { | ||
'items': (0, object_1.fromEntries)(patch.items.entries()), | ||
'itemsDeleted': (_a = patch.itemsDeleted) !== null && _a !== void 0 ? _a : [], | ||
}; | ||
return Object.assign({ 'items': (0, object_1.fromEntries)(patch.items.entries()), 'itemsDeleted': (_a = patch.itemsDeleted) !== null && _a !== void 0 ? _a : [] }, serializeErrors(patch.errors)); | ||
} | ||
@@ -72,2 +80,50 @@ } | ||
exports.serializeCollectionPatch = serializeCollectionPatch; | ||
/** | ||
* For the moment, when the upstream Google Sheet is changed in such a way that the schema has changed, we simply | ||
* stop updates from happening. We do need to alert the user that this has happened, though. This is a utility function | ||
* for creating the appropriate entry in the errors map so that the user can be alerted that updates have stopped | ||
* and what they need to do to fix it. | ||
* | ||
* The eventual, proposed fix is to allow schemas to have version numbers so that changes to the schema from Google | ||
* can simply be folded in to the on-document copies of the data and all following edits. | ||
* | ||
* @param oldPrimaryKey The primary key stored in the data sync service and which currently is used to interpret | ||
* patches. | ||
* @param newPrimaryKey The primary key as it has been changed in the real Google Sheets. | ||
* @returns The error map entry which alerts the document that this problem has happened. | ||
*/ | ||
function schemaOutOfSyncStatus(oldPrimaryKey, newPrimaryKey) { | ||
return [ | ||
collectionerrortypes_1.CollectionUpstreamSchemaStatus, | ||
{ | ||
'dict': { | ||
'status': 'broken', | ||
'onDocumentKey': JSON.stringify(oldPrimaryKey), | ||
'upstreamKey': JSON.stringify(newPrimaryKey), | ||
}, | ||
}, | ||
]; | ||
} | ||
exports.schemaOutOfSyncStatus = schemaOutOfSyncStatus; | ||
/** | ||
* For the moment, when the upstream Google Sheet is changed in such a way that the schema has changed, we simply | ||
* stop updates from happening. We do need to alert the user that this has happened, though. We also need to know when | ||
* the updates are happening properly so we can clear the error once the user has resolved the problem. Since the | ||
* only way to delete errors is to overwrite them, we simply overwrite the error to be OK on every successful | ||
* import. | ||
* @returns The error map entry which alerts the document that this problem has been resolved. | ||
*/ | ||
function schemaOKStatus() { | ||
return [ | ||
collectionerrortypes_1.CollectionUpstreamSchemaStatus, | ||
{ | ||
'dict': { | ||
'status': 'ok', | ||
'onDocumentKey': null, | ||
'upstreamKey': null, | ||
}, | ||
}, | ||
]; | ||
} | ||
exports.schemaOKStatus = schemaOKStatus; | ||
const assertIsJustRenamed = () => undefined; | ||
@@ -74,0 +130,0 @@ assertIsJustRenamed(); |
{ | ||
"name": "lucid-extension-sdk", | ||
"version": "0.0.227", | ||
"version": "0.0.228", | ||
"description": "Utility classes for writing Lucid Software editor extensions", | ||
@@ -5,0 +5,0 @@ "main": "index.js", |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
718359
282
16679