lucid-extension-sdk 0.0.146 → 0.0.148
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/core/data/datasource/alphabet.d.ts +1 -0
- package/core/data/datasource/alphabet.js +31 -0
- package/core/data/datasource/datasourceutils.d.ts +26 -0
- package/core/data/datasource/datasourceutils.js +143 -0
- package/core/data/datasource/serializedimporteddatasource.d.ts +1 -3
- package/core/data/datasource/serializedimporteddatasource.js +0 -1
- package/core/lucidproduct.d.ts +2 -1
- package/core/lucidproduct.js +1 -0
- package/index.d.ts +1 -0
- package/index.js +1 -0
- package/package.json +1 -1
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare const alphabet: string[];
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.alphabet = void 0;
|
|
4
|
+
exports.alphabet = [
|
|
5
|
+
'A',
|
|
6
|
+
'B',
|
|
7
|
+
'C',
|
|
8
|
+
'D',
|
|
9
|
+
'E',
|
|
10
|
+
'F',
|
|
11
|
+
'G',
|
|
12
|
+
'H',
|
|
13
|
+
'I',
|
|
14
|
+
'J',
|
|
15
|
+
'K',
|
|
16
|
+
'L',
|
|
17
|
+
'M',
|
|
18
|
+
'N',
|
|
19
|
+
'O',
|
|
20
|
+
'P',
|
|
21
|
+
'Q',
|
|
22
|
+
'R',
|
|
23
|
+
'S',
|
|
24
|
+
'T',
|
|
25
|
+
'U',
|
|
26
|
+
'V',
|
|
27
|
+
'W',
|
|
28
|
+
'X',
|
|
29
|
+
'Y',
|
|
30
|
+
'Z',
|
|
31
|
+
];
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
import { SerializedFields } from '../serializedfield/serializedfields';
|
|
2
|
+
import { DataSourceType } from './datasourcetype';
|
|
3
|
+
import { SerializedImportedCollection } from './serializedimporteddatasource';
|
|
4
|
+
import { UpstreamUpdateType } from './upstreamupdatetype';
|
|
5
|
+
/** @ignore */
|
|
6
|
+
export declare function alphabetize(n: number): string;
|
|
7
|
+
/** @ignore */
|
|
8
|
+
export declare const MetadataPK = "__PK__";
|
|
9
|
+
/** @ignore until spreadsheet integration is ready for launch (CHART-51946) */
|
|
10
|
+
export declare function makeSerializedImportedCollection(id: string, name: string, rawSchema: string[], data: SerializedFields[], metadata?: {
|
|
11
|
+
[key: string]: SerializedFields[];
|
|
12
|
+
}): SerializedImportedCollection;
|
|
13
|
+
/** @ignore until spreadsheet integration is ready for launch (CHART-51946) */
|
|
14
|
+
export declare function makeSerializedImportedDataSource(id: string, name: string, collections: SerializedImportedCollection[]): {
|
|
15
|
+
Properties: {
|
|
16
|
+
Name: string;
|
|
17
|
+
UpstreamConfig: {
|
|
18
|
+
SourceType: DataSourceType;
|
|
19
|
+
UpdateType: UpstreamUpdateType;
|
|
20
|
+
SourceConfig: {
|
|
21
|
+
spreadsheetId: string;
|
|
22
|
+
};
|
|
23
|
+
};
|
|
24
|
+
};
|
|
25
|
+
Collections: SerializedImportedCollection[];
|
|
26
|
+
};
|
|
@@ -0,0 +1,143 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.makeSerializedImportedDataSource = exports.makeSerializedImportedCollection = exports.MetadataPK = exports.alphabetize = void 0;
|
|
4
|
+
const scalarfieldtype_1 = require("../fieldtypedefinition/scalarfieldtype");
|
|
5
|
+
const alphabet_1 = require("./alphabet");
|
|
6
|
+
const datasourcetype_1 = require("./datasourcetype");
|
|
7
|
+
const upstreamupdatetype_1 = require("./upstreamupdatetype");
|
|
8
|
+
/** @ignore */
|
|
9
|
+
function _alphabetize(n) {
|
|
10
|
+
if (n == undefined || n < 0) {
|
|
11
|
+
return '';
|
|
12
|
+
}
|
|
13
|
+
else if (n < alphabet_1.alphabet.length) {
|
|
14
|
+
return alphabet_1.alphabet[n];
|
|
15
|
+
}
|
|
16
|
+
else {
|
|
17
|
+
return alphabetize(Math.floor(n / alphabet_1.alphabet.length) - 1) + alphabetize(n % alphabet_1.alphabet.length);
|
|
18
|
+
}
|
|
19
|
+
}
|
|
20
|
+
/** @ignore */
|
|
21
|
+
const memoize = new Map();
|
|
22
|
+
/** @ignore */
|
|
23
|
+
function alphabetize(n) {
|
|
24
|
+
const stored = memoize.get(n);
|
|
25
|
+
if (stored != null) {
|
|
26
|
+
return stored;
|
|
27
|
+
}
|
|
28
|
+
const value = _alphabetize(n);
|
|
29
|
+
memoize.set(n, value);
|
|
30
|
+
return value;
|
|
31
|
+
}
|
|
32
|
+
exports.alphabetize = alphabetize;
|
|
33
|
+
/** @ignore */
|
|
34
|
+
function normalizeName(name) {
|
|
35
|
+
return name.trim().toLowerCase();
|
|
36
|
+
}
|
|
37
|
+
/** @ignore */
|
|
38
|
+
exports.MetadataPK = '__PK__';
|
|
39
|
+
/** @ignore */
|
|
40
|
+
function makeSchema(schemaFields) {
|
|
41
|
+
const fields = [];
|
|
42
|
+
const oldToNewFields = new Map();
|
|
43
|
+
const usedFieldsNormalized = new Set([normalizeName(exports.MetadataPK)]);
|
|
44
|
+
schemaFields.forEach((field, index) => {
|
|
45
|
+
// don't add duplicates
|
|
46
|
+
if (!usedFieldsNormalized.has(normalizeName(field))) {
|
|
47
|
+
usedFieldsNormalized.add(normalizeName(field));
|
|
48
|
+
// for now we're changing all schema to the alphabet until preview data can be skipped
|
|
49
|
+
fields.push({ 'Name': alphabetize(index), 'Type': scalarfieldtype_1.ScalarFieldTypeEnum.ANY });
|
|
50
|
+
oldToNewFields.set(field, alphabetize(index));
|
|
51
|
+
}
|
|
52
|
+
});
|
|
53
|
+
return { sheetSchema: { 'Fields': fields, 'PrimaryKey': [] }, oldToNewFields };
|
|
54
|
+
}
|
|
55
|
+
/** @ignore */
|
|
56
|
+
function makeMetadataCollection(metadataType, sheetName, dataItems, sheetSchema) {
|
|
57
|
+
return {
|
|
58
|
+
'Name': sheetName + '|' + metadataType,
|
|
59
|
+
'Schema': sheetSchema,
|
|
60
|
+
'Items': dataItems,
|
|
61
|
+
};
|
|
62
|
+
}
|
|
63
|
+
/** @ignore */
|
|
64
|
+
function makeItemOrderCollection(sheetLength, sheetName) {
|
|
65
|
+
const itemOrderItems = {};
|
|
66
|
+
for (let i = 1; i <= sheetLength; ++i) {
|
|
67
|
+
const rowIndex = i;
|
|
68
|
+
itemOrderItems[`${rowIndex}`] = { 'Key': `${rowIndex}`, 'Order': rowIndex };
|
|
69
|
+
}
|
|
70
|
+
const itemOrderSchema = {
|
|
71
|
+
'Fields': [
|
|
72
|
+
{ 'Name': 'Key', 'Type': scalarfieldtype_1.ScalarFieldTypeEnum.STRING },
|
|
73
|
+
{ 'Name': 'Order', 'Type': scalarfieldtype_1.ScalarFieldTypeEnum.NUMBER },
|
|
74
|
+
],
|
|
75
|
+
'PrimaryKey': ['Order'],
|
|
76
|
+
};
|
|
77
|
+
return makeMetadataCollection('ItemOrder', sheetName, itemOrderItems, itemOrderSchema);
|
|
78
|
+
}
|
|
79
|
+
/** @ignore */
|
|
80
|
+
function makeSerializedItems(rawItems, oldToNewFields, isMetadata = false) {
|
|
81
|
+
const serializedItems = {};
|
|
82
|
+
rawItems.forEach((rawItem, rowIndex) => {
|
|
83
|
+
const dataItem = {};
|
|
84
|
+
for (const [key, field] of Object.entries(rawItem)) {
|
|
85
|
+
const newKey = oldToNewFields.get(key);
|
|
86
|
+
if (newKey) {
|
|
87
|
+
dataItem[newKey] = field;
|
|
88
|
+
}
|
|
89
|
+
}
|
|
90
|
+
const primaryKey = rowIndex + 1;
|
|
91
|
+
if (isMetadata && Object.keys(dataItem).length > 0) {
|
|
92
|
+
dataItem[exports.MetadataPK] = `${primaryKey}`;
|
|
93
|
+
serializedItems[`"${primaryKey}"`] = dataItem;
|
|
94
|
+
}
|
|
95
|
+
else if (!isMetadata) {
|
|
96
|
+
serializedItems[primaryKey] = dataItem;
|
|
97
|
+
}
|
|
98
|
+
});
|
|
99
|
+
return serializedItems;
|
|
100
|
+
}
|
|
101
|
+
/** @ignore until spreadsheet integration is ready for launch (CHART-51946) */
|
|
102
|
+
function makeSerializedImportedCollection(id, name, rawSchema, data, metadata) {
|
|
103
|
+
const { sheetSchema, oldToNewFields } = makeSchema(rawSchema);
|
|
104
|
+
const metadataCollections = {};
|
|
105
|
+
const itemOrderCollection = makeItemOrderCollection(data.length, name);
|
|
106
|
+
metadataCollections['ItemOrder'] = itemOrderCollection;
|
|
107
|
+
if (metadata) {
|
|
108
|
+
const metadataFields = [{ 'Name': exports.MetadataPK, 'Type': scalarfieldtype_1.ScalarFieldTypeEnum.STRING }];
|
|
109
|
+
sheetSchema['Fields'].forEach((field) => metadataFields.push({ 'Name': field['Name'], 'Type': scalarfieldtype_1.ScalarFieldTypeEnum.STRING }));
|
|
110
|
+
const metadataSchema = { 'Fields': metadataFields, 'PrimaryKey': [exports.MetadataPK] };
|
|
111
|
+
for (const [type, data] of Object.entries(metadata)) {
|
|
112
|
+
metadataCollections[type] = makeMetadataCollection(type, name, makeSerializedItems(data, oldToNewFields, true), metadataSchema);
|
|
113
|
+
}
|
|
114
|
+
}
|
|
115
|
+
return {
|
|
116
|
+
'Name': name,
|
|
117
|
+
'Schema': sheetSchema,
|
|
118
|
+
'Items': makeSerializedItems(data, oldToNewFields),
|
|
119
|
+
'UpstreamConfig': {
|
|
120
|
+
'properties': {
|
|
121
|
+
'UpstreamType': upstreamupdatetype_1.UpstreamUpdateType.EVENTPULL,
|
|
122
|
+
'sheetId': id,
|
|
123
|
+
},
|
|
124
|
+
},
|
|
125
|
+
'Metadata': metadataCollections,
|
|
126
|
+
};
|
|
127
|
+
}
|
|
128
|
+
exports.makeSerializedImportedCollection = makeSerializedImportedCollection;
|
|
129
|
+
/** @ignore until spreadsheet integration is ready for launch (CHART-51946) */
|
|
130
|
+
function makeSerializedImportedDataSource(id, name, collections) {
|
|
131
|
+
return {
|
|
132
|
+
'Properties': {
|
|
133
|
+
'Name': name,
|
|
134
|
+
'UpstreamConfig': {
|
|
135
|
+
'SourceType': datasourcetype_1.DataSourceType.DataService,
|
|
136
|
+
'UpdateType': upstreamupdatetype_1.UpstreamUpdateType.EVENTPULL,
|
|
137
|
+
'SourceConfig': { 'spreadsheetId': id },
|
|
138
|
+
},
|
|
139
|
+
},
|
|
140
|
+
'Collections': collections,
|
|
141
|
+
};
|
|
142
|
+
}
|
|
143
|
+
exports.makeSerializedImportedDataSource = makeSerializedImportedDataSource;
|
|
@@ -17,7 +17,7 @@ export declare const isSerializedImportedMetadataCollection: (subject: unknown)
|
|
|
17
17
|
/** @ignore until spreadsheet integration is ready for launch (CHART-51946) */
|
|
18
18
|
export interface SerializedImportedCollection {
|
|
19
19
|
'Name': string;
|
|
20
|
-
'Id'
|
|
20
|
+
'Id'?: string;
|
|
21
21
|
'Schema': SerializedSchema;
|
|
22
22
|
'Items': SerializedDataItems;
|
|
23
23
|
'UpstreamConfig': {
|
|
@@ -30,7 +30,6 @@ export interface SerializedImportedCollection {
|
|
|
30
30
|
/** @ignore until spreadsheet integration is ready for launch (CHART-51946) */
|
|
31
31
|
export declare const isSerializedImportedCollection: (subject: unknown) => subject is import("../../guards").DestructureGuardedTypeObj<{
|
|
32
32
|
Name: typeof isString;
|
|
33
|
-
Id: typeof isString;
|
|
34
33
|
Schema: typeof isSerializedSchema;
|
|
35
34
|
Items: typeof isSerializedDataItems;
|
|
36
35
|
UpstreamConfig: typeof isObject;
|
|
@@ -58,7 +57,6 @@ export declare const isSerializedImportedDataSource: (subject: unknown) => subje
|
|
|
58
57
|
}>;
|
|
59
58
|
Collections: (val: unknown) => val is import("../../guards").DestructureGuardedTypeObj<{
|
|
60
59
|
Name: typeof isString;
|
|
61
|
-
Id: typeof isString;
|
|
62
60
|
Schema: typeof isSerializedSchema;
|
|
63
61
|
Items: typeof isSerializedDataItems;
|
|
64
62
|
UpstreamConfig: typeof isObject;
|
|
@@ -15,7 +15,6 @@ exports.isSerializedImportedMetadataCollection = (0, validators_1.strictObjectVa
|
|
|
15
15
|
/** @ignore until spreadsheet integration is ready for launch (CHART-51946) */
|
|
16
16
|
exports.isSerializedImportedCollection = (0, validators_1.strictObjectValidator)({
|
|
17
17
|
'Name': checks_1.isString,
|
|
18
|
-
'Id': checks_1.isString,
|
|
19
18
|
'Schema': serializedschema_1.isSerializedSchema,
|
|
20
19
|
'Items': serializeddataitems_1.isSerializedDataItems,
|
|
21
20
|
'UpstreamConfig': checks_1.isObject,
|
package/core/lucidproduct.d.ts
CHANGED
package/core/lucidproduct.js
CHANGED
package/index.d.ts
CHANGED
|
@@ -7,6 +7,7 @@ export * from './core/cardintegration/lucidcardintegration';
|
|
|
7
7
|
export * from './core/cardintegration/lucidcardintegrationregistry';
|
|
8
8
|
export * from './core/checks';
|
|
9
9
|
export * from './core/data/datasource/datasourcetype';
|
|
10
|
+
export * from './core/data/datasource/datasourceutils';
|
|
10
11
|
export * from './core/data/datasource/metadatatypes';
|
|
11
12
|
export * from './core/data/datasource/serializeddatasourceproperties';
|
|
12
13
|
export * from './core/data/datasource/serializedimporteddatasource';
|
package/index.js
CHANGED
|
@@ -23,6 +23,7 @@ __exportStar(require("./core/cardintegration/lucidcardintegration"), exports);
|
|
|
23
23
|
__exportStar(require("./core/cardintegration/lucidcardintegrationregistry"), exports);
|
|
24
24
|
__exportStar(require("./core/checks"), exports);
|
|
25
25
|
__exportStar(require("./core/data/datasource/datasourcetype"), exports);
|
|
26
|
+
__exportStar(require("./core/data/datasource/datasourceutils"), exports);
|
|
26
27
|
__exportStar(require("./core/data/datasource/metadatatypes"), exports);
|
|
27
28
|
__exportStar(require("./core/data/datasource/serializeddatasourceproperties"), exports);
|
|
28
29
|
__exportStar(require("./core/data/datasource/serializedimporteddatasource"), exports);
|