lucid-extension-sdk 0.0.125 → 0.0.127

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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "lucid-extension-sdk",
3
- "version": "0.0.125",
3
+ "version": "0.0.127",
4
4
  "description": "Utility classes for writing Lucid Software editor extensions",
5
5
  "main": "sdk/index.js",
6
6
  "types": "sdk/index.d.ts",
@@ -27,6 +27,7 @@ export declare const enum CommandName {
27
27
  AddSpreadsheetIntegration = "asi",
28
28
  Alert = "a",
29
29
  AnimateViewport = "av",
30
+ AwaitDataSourceImport = "adi",
30
31
  AwaitImport = "ai",
31
32
  Bootstrap = "b",
32
33
  CancelDragBlockToCanvas = "cdc",
@@ -91,6 +92,7 @@ export declare const enum CommandName {
91
92
  RegisterUnfurl = "ru",
92
93
  ReloadExtension = "r",
93
94
  SendOAuthRequest = "oauth",
95
+ SendAsyncOAuthRequest = "aoauth",
94
96
  SendPermanentTokenRequest = "perm",
95
97
  SendUIMessage = "suim",
96
98
  SendXHR = "xhr",
@@ -149,6 +151,10 @@ export declare type CommandArgs = {
149
151
  query: AnimateViewportQuery;
150
152
  result: AnimateViewportResult;
151
153
  };
154
+ [CommandName.AwaitDataSourceImport]: {
155
+ query: AwaitDataSourceImportQuery;
156
+ result: AwaitDataSourceImportResult;
157
+ };
152
158
  [CommandName.AwaitImport]: {
153
159
  query: AwaitImportQuery;
154
160
  result: AwaitImportResult;
@@ -405,6 +411,10 @@ export declare type CommandArgs = {
405
411
  query: SendOAuthRequestQuery;
406
412
  result: SendOAuthRequestResponse;
407
413
  };
414
+ [CommandName.SendAsyncOAuthRequest]: {
415
+ query: SendAsyncOAuthRequestQuery;
416
+ result: SendOAuthRequestResponse;
417
+ };
408
418
  [CommandName.SendPermanentTokenRequest]: {
409
419
  query: SendPermanentTokenRequestQuery;
410
420
  result: SendOAuthRequestResponse;
@@ -612,6 +622,14 @@ export declare type AlertQuery = {
612
622
  };
613
623
  /** True if they click OK, false otherwise */
614
624
  export declare type AlertResult = Promise<boolean>;
625
+ export declare type AwaitDataSourceImportQuery = {
626
+ /** Data Connector Name */
627
+ 'n': string;
628
+ /** Sync data source ID Nonce */
629
+ 's': string;
630
+ };
631
+ /** Promise resolving to the data source ID where the data arrived */
632
+ export declare type AwaitDataSourceImportResult = Promise<string>;
615
633
  export declare type AwaitImportQuery = {
616
634
  /** Data Connector Name */
617
635
  'n': string;
@@ -1012,6 +1030,10 @@ export declare type SendOAuthRequestQuery = SendXHRQuery & {
1012
1030
  /** Post Result To */
1013
1031
  'prt'?: string | undefined;
1014
1032
  };
1033
+ export declare type SendAsyncOAuthRequestQuery = SendXHRQuery & {
1034
+ /** OAuth provider name as specified in the package manifest */
1035
+ 'p': string;
1036
+ };
1015
1037
  export declare type SendPermanentTokenRequestQuery = SendXHRQuery & {
1016
1038
  /** Permanent token provider name as specified in the package manifest */
1017
1039
  'p': string;
@@ -11,6 +11,7 @@ exports.commandTitles = new Map([
11
11
  ["asi" /* CommandName.AddSpreadsheetIntegration */, 'AddSpreadsheetIntegration'],
12
12
  ["a" /* CommandName.Alert */, 'Alert'],
13
13
  ["av" /* CommandName.AnimateViewport */, 'AnimateViewport'],
14
+ ["adi" /* CommandName.AwaitDataSourceImport */, 'AwaitDataSourceImport'],
14
15
  ["ai" /* CommandName.AwaitImport */, 'AwaitImport'],
15
16
  ["b" /* CommandName.Bootstrap */, 'Bootstrap'],
16
17
  ["ceps" /* CommandName.CanEditPackageSettings */, 'CanEditPackageSettings'],
@@ -73,6 +74,7 @@ exports.commandTitles = new Map([
73
74
  ["ru" /* CommandName.RegisterUnfurl */, 'RegisterUnfurl'],
74
75
  ["r" /* CommandName.ReloadExtension */, 'ReloadExtension'],
75
76
  ["oauth" /* CommandName.SendOAuthRequest */, 'SendOAuthRequest'],
77
+ ["aoauth" /* CommandName.SendAsyncOAuthRequest */, 'SendAsyncOAuthRequest'],
76
78
  ["suim" /* CommandName.SendUIMessage */, 'SendUIMessage'],
77
79
  ["xhr" /* CommandName.SendXHR */, 'SendXHR'],
78
80
  ["scp" /* CommandName.SetCurrentPage */, 'SetCurrentPage'],
@@ -1,7 +1,7 @@
1
1
  import { FieldDefinition } from '../../data/schemadefinition';
2
2
  import { isString } from '../checks';
3
3
  import { isSerializedFieldTypeDefinition } from '../data/fieldtypedefinition/fieldtypedefinition';
4
- import { FieldConstraintType, SerializedFieldDefinition } from '../data/serializedfield/serializedfielddefinition';
4
+ import { SerializedFieldDefinition } from '../data/serializedfield/serializedfielddefinition';
5
5
  import { isSerializedFieldType, SerializedFieldType } from '../data/serializedfield/serializedfields';
6
6
  /** For fields with Option or ApiOption type, the label and value for each available option */
7
7
  export interface ExtensionCardFieldOption {
@@ -62,17 +62,13 @@ export declare const isSerializedFieldOptions: (p1: unknown) => p1 is import("..
62
62
  v: typeof isSerializedFieldType;
63
63
  i: (x: unknown) => x is string | undefined;
64
64
  }>[];
65
- export declare const isSerializedFieldConstraint: (subject: unknown) => subject is import("../guards").DestructureGuardedTypeObj<{
66
- Type: (x: unknown) => x is FieldConstraintType;
67
- Details: (x: unknown) => x is number | undefined;
68
- }>;
69
65
  /** @ignore */
70
66
  export declare const isSerializedExtensionCardFieldDefinition: (subject: unknown) => subject is import("../guards").DestructureGuardedTypeObj<{
71
67
  Name: typeof isString;
72
68
  Type: typeof isSerializedFieldTypeDefinition;
73
69
  Constraints: (x: unknown) => x is import("../guards").DestructureGuardedTypeObj<{
74
- Type: (x: unknown) => x is FieldConstraintType;
75
- Details: (x: unknown) => x is number | undefined;
70
+ Type: (x: unknown) => x is import("../data/serializedfield/serializedfielddefinition").FieldConstraintType;
71
+ Details: (x: unknown) => x is unknown;
76
72
  }>[] | undefined;
77
73
  l: typeof isString;
78
74
  d: (x: unknown) => x is string | undefined;
@@ -1,6 +1,6 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.deserializeCardFieldArrayDefinition = exports.deserializeCardFieldDefinition = exports.isSerializedExtensionCardFieldDefinition = exports.isSerializedFieldConstraint = exports.isSerializedFieldOptions = exports.isSerializedFieldOption = exports.deserializeFieldOption = exports.serializeCardFieldArrayDefinition = exports.serializeCardFieldDefinition = exports.serializeCardFieldOption = void 0;
3
+ exports.deserializeCardFieldArrayDefinition = exports.deserializeCardFieldDefinition = exports.isSerializedExtensionCardFieldDefinition = exports.isSerializedFieldOptions = exports.isSerializedFieldOption = exports.deserializeFieldOption = exports.serializeCardFieldArrayDefinition = exports.serializeCardFieldDefinition = exports.serializeCardFieldOption = void 0;
4
4
  const schemadefinition_1 = require("../../data/schemadefinition");
5
5
  const checks_1 = require("../checks");
6
6
  const fieldtypedefinition_1 = require("../data/fieldtypedefinition/fieldtypedefinition");
@@ -42,15 +42,11 @@ exports.isSerializedFieldOption = (0, validators_1.objectValidator)({
42
42
  'i': (0, validators_1.option)(checks_1.isString),
43
43
  });
44
44
  exports.isSerializedFieldOptions = (0, validators_1.arrayValidator)(exports.isSerializedFieldOption);
45
- exports.isSerializedFieldConstraint = (0, validators_1.objectValidator)({
46
- 'Type': (0, validators_1.enumValidator)(serializedfielddefinition_1.FieldConstraintType),
47
- 'Details': (0, validators_1.option)(checks_1.isNumber),
48
- });
49
45
  /** @ignore */
50
46
  exports.isSerializedExtensionCardFieldDefinition = (0, validators_1.objectValidator)({
51
47
  'Name': checks_1.isString,
52
48
  'Type': fieldtypedefinition_1.isSerializedFieldTypeDefinition,
53
- 'Constraints': (0, validators_1.option)((0, validators_1.arrayValidator)(exports.isSerializedFieldConstraint)),
49
+ 'Constraints': (0, validators_1.option)((0, validators_1.arrayValidator)(serializedfielddefinition_1.isSerializedFieldConstraint)),
54
50
  'l': checks_1.isString,
55
51
  'd': (0, validators_1.option)(checks_1.isString),
56
52
  'def': (0, validators_1.option)(serializedfields_1.isSerializedFieldType),
@@ -1,6 +1,17 @@
1
+ import { isString } from '../../checks';
1
2
  import { SerializedUpstreamConfig } from './serializedupstreamconfig';
2
3
  /** @ignore until spreadsheet integration is ready for launch (CHART-51946) */
3
4
  export interface SerializedDataSourceProperties {
4
5
  'Name': string;
5
6
  'UpstreamConfig'?: SerializedUpstreamConfig | null | undefined;
6
7
  }
8
+ /** @ignore until spreadsheet integration is ready for launch (CHART-51946) */
9
+ export declare const isSerializedDataSourceProperties: (subject: unknown) => subject is import("../../guards").DestructureGuardedTypeObj<{
10
+ Name: typeof isString;
11
+ UpstreamConfig: (x: unknown) => x is import("../../guards").DestructureGuardedTypeObj<{
12
+ SourceType: (x: unknown) => x is import("./datasourcetype").DataSourceType;
13
+ UpdateType: (x: unknown) => x is import("./upstreamupdatetype").UpstreamUpdateType;
14
+ PatchType: (x: unknown) => x is import("./upstreampatchtype").UpstreamPatchType | null | undefined;
15
+ SourceConfig: typeof import("../../checks").isObject;
16
+ }> | null | undefined;
17
+ }>;
@@ -1,2 +1,11 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.isSerializedDataSourceProperties = void 0;
4
+ const checks_1 = require("../../checks");
5
+ const validators_1 = require("../../validators/validators");
6
+ const serializedupstreamconfig_1 = require("./serializedupstreamconfig");
7
+ /** @ignore until spreadsheet integration is ready for launch (CHART-51946) */
8
+ exports.isSerializedDataSourceProperties = (0, validators_1.strictObjectValidator)({
9
+ 'Name': checks_1.isString,
10
+ 'UpstreamConfig': (0, validators_1.nullableOption)(serializedupstreamconfig_1.isSerializedUpstreamConfig),
11
+ });
@@ -1,5 +1,6 @@
1
- import { SerializedDataItems } from '../serializedfield/serializeddataitems';
2
- import { SerializedSchema } from '../serializedfield/serializedschema';
1
+ import { isObject, isString } from '../../checks';
2
+ import { isSerializedDataItems, SerializedDataItems } from '../serializedfield/serializeddataitems';
3
+ import { isSerializedSchema, SerializedSchema } from '../serializedfield/serializedschema';
3
4
  import { SerializedDataSourceProperties } from './serializeddatasourceproperties';
4
5
  /** @ignore until spreadsheet integration is ready for launch (CHART-51946) */
5
6
  export interface SerializedImportedMetadataCollection {
@@ -8,6 +9,12 @@ export interface SerializedImportedMetadataCollection {
8
9
  'Items': SerializedDataItems;
9
10
  }
10
11
  /** @ignore until spreadsheet integration is ready for launch (CHART-51946) */
12
+ export declare const isSerializedImportedMetadataCollection: (subject: unknown) => subject is import("../../guards").DestructureGuardedTypeObj<{
13
+ Name: typeof isString;
14
+ Schema: typeof isSerializedSchema;
15
+ Items: typeof isSerializedDataItems;
16
+ }>;
17
+ /** @ignore until spreadsheet integration is ready for launch (CHART-51946) */
11
18
  export interface SerializedImportedCollection {
12
19
  'Name': string;
13
20
  'Schema': SerializedSchema;
@@ -20,7 +27,42 @@ export interface SerializedImportedCollection {
20
27
  };
21
28
  }
22
29
  /** @ignore until spreadsheet integration is ready for launch (CHART-51946) */
30
+ export declare const isSerializedImportedCollection: (subject: unknown) => subject is import("../../guards").DestructureGuardedTypeObj<{
31
+ Name: typeof isString;
32
+ Schema: typeof isSerializedSchema;
33
+ Items: typeof isSerializedDataItems;
34
+ UpstreamConfig: typeof isObject;
35
+ Metadata: (val: unknown) => val is Record<string, import("../../guards").DestructureGuardedTypeObj<{
36
+ Name: typeof isString;
37
+ Schema: typeof isSerializedSchema;
38
+ Items: typeof isSerializedDataItems;
39
+ }>>;
40
+ }>;
41
+ /** @ignore until spreadsheet integration is ready for launch (CHART-51946) */
23
42
  export interface SerializedImportedDataSource {
24
43
  'Properties': SerializedDataSourceProperties;
25
44
  'Collections': SerializedImportedCollection[];
26
45
  }
46
+ /** @ignore until spreadsheet integration is ready for launch (CHART-51946) */
47
+ export declare const isSerializedImportedDataSource: (subject: unknown) => subject is import("../../guards").DestructureGuardedTypeObj<{
48
+ Properties: (subject: unknown) => subject is import("../../guards").DestructureGuardedTypeObj<{
49
+ Name: typeof isString;
50
+ UpstreamConfig: (x: unknown) => x is import("../../guards").DestructureGuardedTypeObj<{
51
+ SourceType: (x: unknown) => x is import("./datasourcetype").DataSourceType;
52
+ UpdateType: (x: unknown) => x is import("./upstreamupdatetype").UpstreamUpdateType;
53
+ PatchType: (x: unknown) => x is import("./upstreampatchtype").UpstreamPatchType | null | undefined;
54
+ SourceConfig: typeof isObject;
55
+ }> | null | undefined;
56
+ }>;
57
+ Collections: (val: unknown) => val is import("../../guards").DestructureGuardedTypeObj<{
58
+ Name: typeof isString;
59
+ Schema: typeof isSerializedSchema;
60
+ Items: typeof isSerializedDataItems;
61
+ UpstreamConfig: typeof isObject;
62
+ Metadata: (val: unknown) => val is Record<string, import("../../guards").DestructureGuardedTypeObj<{
63
+ Name: typeof isString;
64
+ Schema: typeof isSerializedSchema;
65
+ Items: typeof isSerializedDataItems;
66
+ }>>;
67
+ }>[];
68
+ }>;
@@ -1,2 +1,27 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.isSerializedImportedDataSource = exports.isSerializedImportedCollection = exports.isSerializedImportedMetadataCollection = void 0;
4
+ const checks_1 = require("../../checks");
5
+ const validators_1 = require("../../validators/validators");
6
+ const serializeddataitems_1 = require("../serializedfield/serializeddataitems");
7
+ const serializedschema_1 = require("../serializedfield/serializedschema");
8
+ const serializeddatasourceproperties_1 = require("./serializeddatasourceproperties");
9
+ /** @ignore until spreadsheet integration is ready for launch (CHART-51946) */
10
+ exports.isSerializedImportedMetadataCollection = (0, validators_1.strictObjectValidator)({
11
+ 'Name': checks_1.isString,
12
+ 'Schema': serializedschema_1.isSerializedSchema,
13
+ 'Items': serializeddataitems_1.isSerializedDataItems,
14
+ });
15
+ /** @ignore until spreadsheet integration is ready for launch (CHART-51946) */
16
+ exports.isSerializedImportedCollection = (0, validators_1.strictObjectValidator)({
17
+ 'Name': checks_1.isString,
18
+ 'Schema': serializedschema_1.isSerializedSchema,
19
+ 'Items': serializeddataitems_1.isSerializedDataItems,
20
+ 'UpstreamConfig': checks_1.isObject,
21
+ 'Metadata': (0, checks_1.isRecord)(exports.isSerializedImportedMetadataCollection),
22
+ });
23
+ /** @ignore until spreadsheet integration is ready for launch (CHART-51946) */
24
+ exports.isSerializedImportedDataSource = (0, validators_1.strictObjectValidator)({
25
+ 'Properties': serializeddatasourceproperties_1.isSerializedDataSourceProperties,
26
+ 'Collections': (0, checks_1.isTypedArray)(exports.isSerializedImportedCollection),
27
+ });
@@ -1,3 +1,4 @@
1
+ import { isObject } from '../../checks';
1
2
  import { DataSourceType } from './datasourcetype';
2
3
  import { UpstreamPatchType } from './upstreampatchtype';
3
4
  import { UpstreamUpdateType } from './upstreamupdatetype';
@@ -10,3 +11,10 @@ export interface SerializedUpstreamConfig {
10
11
  [index: string]: any;
11
12
  };
12
13
  }
14
+ /** @ignore until spreadsheet integration is ready for launch (CHART-51946) */
15
+ export declare const isSerializedUpstreamConfig: (subject: unknown) => subject is import("../../guards").DestructureGuardedTypeObj<{
16
+ SourceType: (x: unknown) => x is DataSourceType;
17
+ UpdateType: (x: unknown) => x is UpstreamUpdateType;
18
+ PatchType: (x: unknown) => x is UpstreamPatchType | null | undefined;
19
+ SourceConfig: typeof isObject;
20
+ }>;
@@ -1,2 +1,15 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.isSerializedUpstreamConfig = void 0;
4
+ const checks_1 = require("../../checks");
5
+ const validators_1 = require("../../validators/validators");
6
+ const datasourcetype_1 = require("./datasourcetype");
7
+ const upstreampatchtype_1 = require("./upstreampatchtype");
8
+ const upstreamupdatetype_1 = require("./upstreamupdatetype");
9
+ /** @ignore until spreadsheet integration is ready for launch (CHART-51946) */
10
+ exports.isSerializedUpstreamConfig = (0, validators_1.strictObjectValidator)({
11
+ 'SourceType': (0, validators_1.enumValidator)(datasourcetype_1.DataSourceType),
12
+ 'UpdateType': (0, validators_1.enumValidator)(upstreamupdatetype_1.UpstreamUpdateType),
13
+ 'PatchType': (0, validators_1.nullableOption)((0, validators_1.enumValidator)(upstreampatchtype_1.UpstreamPatchType)),
14
+ 'SourceConfig': checks_1.isObject,
15
+ });
@@ -1,13 +1,7 @@
1
+ import { isString } from '../../checks';
1
2
  import { JsonSerializable } from '../../jsonserializable';
2
- import { SerializedFieldTypeDefinition } from '../fieldtypedefinition/fieldtypedefinition';
3
+ import { isSerializedFieldTypeDefinition, SerializedFieldTypeDefinition } from '../fieldtypedefinition/fieldtypedefinition';
3
4
  import { SemanticKind } from '../fieldtypedefinition/semantickind';
4
- export declare type SerializedFieldDefinition = {
5
- 'Name': string;
6
- 'Type': SerializedFieldTypeDefinition;
7
- 'Constraints'?: SerializedFieldConstraint[] | undefined;
8
- 'SyncSchema'?: string | undefined;
9
- 'Mapping'?: readonly SemanticKind[] | undefined;
10
- };
11
5
  export declare enum FieldConstraintType {
12
6
  REQUIRED = "required",
13
7
  LOCKED = "locked",
@@ -21,3 +15,24 @@ export declare type SerializedFieldConstraint = {
21
15
  'Type': FieldConstraintType;
22
16
  'Details'?: JsonSerializable;
23
17
  };
18
+ export declare const isSerializedFieldConstraint: (subject: unknown) => subject is import("../../guards").DestructureGuardedTypeObj<{
19
+ Type: (x: unknown) => x is FieldConstraintType;
20
+ Details: (x: unknown) => x is unknown;
21
+ }>;
22
+ export declare type SerializedFieldDefinition = {
23
+ 'Name': string;
24
+ 'Type': SerializedFieldTypeDefinition;
25
+ 'Constraints'?: SerializedFieldConstraint[] | undefined;
26
+ 'SyncSchema'?: string | undefined;
27
+ 'Mapping'?: readonly SemanticKind[] | undefined;
28
+ };
29
+ export declare const isSerializedFieldDefinition: (subject: unknown) => subject is import("../../guards").DestructureGuardedTypeObj<{
30
+ Name: typeof isString;
31
+ Type: typeof isSerializedFieldTypeDefinition;
32
+ Constraints: (x: unknown) => x is import("../../guards").DestructureGuardedTypeObj<{
33
+ Type: (x: unknown) => x is FieldConstraintType;
34
+ Details: (x: unknown) => x is unknown;
35
+ }>[] | undefined;
36
+ SyncSchema: (x: unknown) => x is string | undefined;
37
+ Mapping: (x: unknown) => x is SemanticKind[] | undefined;
38
+ }>;
@@ -1,7 +1,10 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.isFieldConstraintType = exports.FieldConstraintType = void 0;
3
+ exports.isSerializedFieldDefinition = exports.isSerializedFieldConstraint = exports.isFieldConstraintType = exports.FieldConstraintType = void 0;
4
+ const checks_1 = require("../../checks");
4
5
  const validators_1 = require("../../validators/validators");
6
+ const fieldtypedefinition_1 = require("../fieldtypedefinition/fieldtypedefinition");
7
+ const semantickind_1 = require("../fieldtypedefinition/semantickind");
5
8
  // The options here must match com.lucidchart.data.model.fielddefinition.FieldConstraintType on the backend
6
9
  var FieldConstraintType;
7
10
  (function (FieldConstraintType) {
@@ -13,3 +16,14 @@ var FieldConstraintType;
13
16
  FieldConstraintType["NO_WHITESPACE"] = "noWhitespace";
14
17
  })(FieldConstraintType = exports.FieldConstraintType || (exports.FieldConstraintType = {}));
15
18
  exports.isFieldConstraintType = (0, validators_1.enumValidator)(FieldConstraintType);
19
+ exports.isSerializedFieldConstraint = (0, validators_1.objectValidator)({
20
+ 'Type': (0, validators_1.enumValidator)(FieldConstraintType),
21
+ 'Details': (0, validators_1.option)(checks_1.isUnknown),
22
+ });
23
+ exports.isSerializedFieldDefinition = (0, validators_1.strictObjectValidator)({
24
+ 'Name': checks_1.isString,
25
+ 'Type': fieldtypedefinition_1.isSerializedFieldTypeDefinition,
26
+ 'Constraints': (0, validators_1.option)((0, validators_1.arrayValidator)(exports.isSerializedFieldConstraint)),
27
+ 'SyncSchema': (0, validators_1.option)(checks_1.isString),
28
+ 'Mapping': (0, validators_1.option)((0, validators_1.arrayValidator)((0, validators_1.stringEnumValidator)(semantickind_1.SemanticKind))),
29
+ });
@@ -7,3 +7,4 @@ export declare type SerializedSchema = {
7
7
  'PrimaryKey': string[];
8
8
  'FieldLabelOverrides'?: SerializedLabelOverrides | undefined;
9
9
  };
10
+ export declare function isSerializedSchema(schema: any): schema is SerializedSchema;
@@ -1,2 +1,23 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.isSerializedSchema = void 0;
4
+ const checks_1 = require("../../checks");
5
+ const validators_1 = require("../../validators/validators");
6
+ const serializedfielddefinition_1 = require("./serializedfielddefinition");
7
+ function isSerializedSchema(schema) {
8
+ if (schema == null) {
9
+ return false;
10
+ }
11
+ const fields = schema['Fields'];
12
+ const primaryKey = schema['PrimaryKey'];
13
+ const fieldLabelOverrides = schema['FieldLabelOverrides'];
14
+ const validOverrides = (0, checks_1.isDefAndNotNull)(fieldLabelOverrides)
15
+ ? (0, checks_1.isRecord)(checks_1.isString)(fieldLabelOverrides) && !(0, checks_1.isArray)(fieldLabelOverrides)
16
+ : true; // Optional field
17
+ return ((0, checks_1.isTypedArray)(serializedfielddefinition_1.isSerializedFieldDefinition)(fields) &&
18
+ (0, validators_1.arrayValidator)(serializedfielddefinition_1.isSerializedFieldDefinition)(fields) &&
19
+ (0, checks_1.isArray)(primaryKey) &&
20
+ primaryKey.every(checks_1.isString) &&
21
+ validOverrides);
22
+ }
23
+ exports.isSerializedSchema = isSerializedSchema;
@@ -1,5 +1,5 @@
1
- import { CollectionProxy } from '../../data/collectionproxy';
2
1
  import { SerializedImportedDataSource } from '../data/datasource/serializedimporteddatasource';
2
+ import { JsonSerializable } from '../jsonserializable';
3
3
  /** @ignore until spreadsheet integration is ready for launch (CHART-51946) */
4
4
  export declare enum LucidSpreadsheetIntegrationFailureType {
5
5
  AuthorizationFailure = "AuthorizationFailure",
@@ -9,12 +9,16 @@ export declare enum LucidSpreadsheetIntegrationFailureType {
9
9
  /** @ignore until spreadsheet integration is ready for launch (CHART-51946) */
10
10
  export declare const lucidSpreadsheetIntegrationFailureTypeValidator: (x: unknown) => x is LucidSpreadsheetIntegrationFailureType;
11
11
  /** @ignore until spreadsheet integration is ready for launch (CHART-51946) */
12
- export declare abstract class LucidSpreadsheetIntegration<CONFIG, SHEET> {
12
+ export declare abstract class LucidSpreadsheetIntegration<CONFIG extends JsonSerializable, SHEET extends JsonSerializable> {
13
13
  abstract name: string;
14
14
  abstract label: string;
15
15
  abstract iconUrl: string;
16
- abstract getSpreadsheetToImportDetails: () => Promise<CONFIG | LucidSpreadsheetIntegrationFailureType>;
16
+ abstract getSpreadsheetToImportDetails(): Promise<CONFIG | LucidSpreadsheetIntegrationFailureType>;
17
17
  abstract getSpreadsheetSheetIdsAndNames(spreadsheetDetails: CONFIG): Promise<Map<SHEET, string> | LucidSpreadsheetIntegrationFailureType>;
18
- abstract getPreviewData(spreadsheetDetails: CONFIG, sheetIdsToPreview: SHEET[]): Promise<SerializedImportedDataSource | LucidSpreadsheetIntegrationFailureType>;
19
- abstract importSheets(spreadsheetDetails: CONFIG, sheetIdsToImport: SHEET[]): Promise<CollectionProxy[] | LucidSpreadsheetIntegrationFailureType>;
18
+ abstract getPreviewData(spreadsheetDetails: CONFIG, sheetsToPreview: SHEET[]): Promise<SerializedImportedDataSource | LucidSpreadsheetIntegrationFailureType>;
19
+ abstract importSheets(spreadsheetDetails: CONFIG, sheetsToImportConfig: {
20
+ 'sheet': SHEET;
21
+ 'headerRowIndex': number;
22
+ 'primaryKeys': string[];
23
+ }[]): Promise<string | LucidSpreadsheetIntegrationFailureType>;
20
24
  }
@@ -1,4 +1,5 @@
1
1
  import { EditorClient } from '../../editorclient';
2
+ import { JsonSerializable } from '../jsonserializable';
2
3
  import { LucidSpreadsheetIntegration } from './lucidspreadsheetintegration';
3
4
  /** @ignore until spreadsheet integration is ready for launch (CHART-51946) */
4
5
  export declare class LucidSpreadsheetIntegrationRegistry {
@@ -7,5 +8,5 @@ export declare class LucidSpreadsheetIntegrationRegistry {
7
8
  /**
8
9
  * Register a spreadsheet integration.
9
10
  */
10
- static addSpreadsheetIntegration<CONFIG, SHEET>(client: EditorClient, spreadsheetIntegration: LucidSpreadsheetIntegration<CONFIG, SHEET>): void;
11
+ static addSpreadsheetIntegration<CONFIG extends JsonSerializable, SHEET extends JsonSerializable>(client: EditorClient, spreadsheetIntegration: LucidSpreadsheetIntegration<CONFIG, SHEET>): void;
11
12
  }
@@ -13,29 +13,42 @@ class LucidSpreadsheetIntegrationRegistry {
13
13
  static addSpreadsheetIntegration(client, spreadsheetIntegration) {
14
14
  const getSpreadsheetToImportDetailsActionName = LucidSpreadsheetIntegrationRegistry.nextHookName();
15
15
  client.registerAction(getSpreadsheetToImportDetailsActionName, async () => {
16
- const result = await spreadsheetIntegration.getSpreadsheetToImportDetails();
17
- return result;
16
+ try {
17
+ return await spreadsheetIntegration.getSpreadsheetToImportDetails();
18
+ }
19
+ catch (error) { }
20
+ return lucidspreadsheetintegration_1.LucidSpreadsheetIntegrationFailureType.GenericFailure;
18
21
  });
19
22
  const getSpreadsheetSheetIdsAndNamesActionName = LucidSpreadsheetIntegrationRegistry.nextHookName();
20
23
  client.registerAction(getSpreadsheetSheetIdsAndNamesActionName, async (message) => {
21
- const result = await spreadsheetIntegration.getSpreadsheetSheetIdsAndNames(message['dataDetails']);
22
- if ((0, lucidspreadsheetintegration_1.lucidSpreadsheetIntegrationFailureTypeValidator)(result)) {
23
- return result;
24
- }
25
- else {
26
- // Serialize the Map
27
- return Array.from(result);
24
+ try {
25
+ const result = await spreadsheetIntegration.getSpreadsheetSheetIdsAndNames(message['dataDetails']);
26
+ if ((0, lucidspreadsheetintegration_1.lucidSpreadsheetIntegrationFailureTypeValidator)(result)) {
27
+ return result;
28
+ }
29
+ else {
30
+ // Serialize the Map
31
+ return Array.from(result);
32
+ }
28
33
  }
34
+ catch (error) { }
35
+ return lucidspreadsheetintegration_1.LucidSpreadsheetIntegrationFailureType.GenericFailure;
29
36
  });
30
37
  const getPreviewDataActionName = LucidSpreadsheetIntegrationRegistry.nextHookName();
31
38
  client.registerAction(getPreviewDataActionName, async (message) => {
32
- const result = await spreadsheetIntegration.getPreviewData(message['dataDetails'], message['sheetIds']);
33
- return result;
39
+ try {
40
+ return await spreadsheetIntegration.getPreviewData(message['dataDetails'], message['sheets']);
41
+ }
42
+ catch (error) { }
43
+ return lucidspreadsheetintegration_1.LucidSpreadsheetIntegrationFailureType.GenericFailure;
34
44
  });
35
45
  const importSheetsActionName = LucidSpreadsheetIntegrationRegistry.nextHookName();
36
46
  client.registerAction(importSheetsActionName, async (message) => {
37
- const result = await spreadsheetIntegration.importSheets(message['dataDetails'], message['sheetIds']);
38
- return result;
47
+ try {
48
+ return await spreadsheetIntegration.importSheets(message['dataDetails'], message['sheetsToImportConfig']);
49
+ }
50
+ catch (error) { }
51
+ return lucidspreadsheetintegration_1.LucidSpreadsheetIntegrationFailureType.GenericFailure;
39
52
  });
40
53
  const serialized = {
41
54
  'n': spreadsheetIntegration.name,
@@ -92,6 +92,8 @@ export declare class EditorClient {
92
92
  */
93
93
  canEditPackageSettings(): Promise<boolean>;
94
94
  awaitDataImport(dataConnectorName: string, syncDataSourceId: undefined | string, syncCollectionId: string, primaryKeys: string[], timeout?: number): Promise<CollectionProxy>;
95
+ /** @ignore until spreadsheet integration is ready for launch (CHART-51946) */
96
+ awaitDataSourceImport(dataConnectorName: string, syncDataSourceIdNonce: string): Promise<string>;
95
97
  /**
96
98
  * Make a network request
97
99
  * @param request Settings for the network request
@@ -105,6 +107,28 @@ export declare class EditorClient {
105
107
  responseFormat: 'binary';
106
108
  }): Promise<BinaryXHRResponse>;
107
109
  xhr(request: XHRRequest): Promise<XHRResponse>;
110
+ /**
111
+ * Make an asyncronous OAuth network request. The request is enqueued to eventually execute. The request may be attempted multiple times with
112
+ * an overall timeout of 120 seconds.
113
+ * @param providerName Name of the OAuth provider
114
+ * @param request Settings for the request
115
+ * @returns A promise that will either resolve or reject with an XHRResponse. If the HTTP status
116
+ * code is not 2xx, the promise will reject.
117
+ */
118
+ asyncOAuthXhr(providerName: string, request: OAuthXHRRequest & {
119
+ responseFormat: 'utf8';
120
+ }): Promise<TextXHRResponse>;
121
+ asyncOAuthXhr(providerName: string, request: OAuthXHRRequest & {
122
+ responseFormat: 'binary';
123
+ }): Promise<BinaryXHRResponse>;
124
+ asyncOAuthXhr(providerName: string, request: OAuthXHRRequest): Promise<XHRResponse>;
125
+ /**
126
+ * Make an OAuth network request. Make the request immediately and only once with a 10 second timeout.
127
+ * @param providerName Name of the OAuth provider
128
+ * @param request Settings for the request
129
+ * @returns A promise that will either resolve or reject with an XHRResponse. If the HTTP status
130
+ * code is not 2xx, the promise will reject.
131
+ */
108
132
  oauthXhr(providerName: string, request: OAuthXHRRequest & {
109
133
  responseFormat: 'utf8';
110
134
  }): Promise<TextXHRResponse>;
@@ -158,6 +158,13 @@ class EditorClient {
158
158
  't': timeout,
159
159
  }), this);
160
160
  }
161
+ /** @ignore until spreadsheet integration is ready for launch (CHART-51946) */
162
+ async awaitDataSourceImport(dataConnectorName, syncDataSourceIdNonce) {
163
+ return await this.sendCommand("adi" /* CommandName.AwaitDataSourceImport */, {
164
+ 'n': dataConnectorName,
165
+ 's': syncDataSourceIdNonce,
166
+ });
167
+ }
161
168
  xhr(request) {
162
169
  const responseFormat = request.responseFormat || 'utf8';
163
170
  return this.sendCommand("xhr" /* CommandName.SendXHR */, {
@@ -176,6 +183,17 @@ class EditorClient {
176
183
  throw parseRawXHRResponse(responseFormat, raw);
177
184
  });
178
185
  }
186
+ asyncOAuthXhr(providerName, request) {
187
+ const responseFormat = request.responseFormat || 'utf8';
188
+ return this.sendCommand("aoauth" /* CommandName.SendAsyncOAuthRequest */, Object.assign({ 'url': request.url, 'm': request.method, 'd': request.data, 'h': request.headers, 'ms': request.timeoutMs, 'p': providerName, 'f': responseFormat }, (request.postResultTo ? { 'prt': request.postResultTo } : {})))
189
+ .then((raw) => {
190
+ return parseRawXHRResponse(responseFormat, raw);
191
+ })
192
+ .catch((error) => {
193
+ const raw = (0, commandtypes_1.isRawSendXHRResponse)(error) ? error : undefined;
194
+ throw parseRawXHRResponse(responseFormat, raw);
195
+ });
196
+ }
179
197
  oauthXhr(providerName, request) {
180
198
  const responseFormat = request.responseFormat || 'utf8';
181
199
  return this.sendCommand("oauth" /* CommandName.SendOAuthRequest */, Object.assign({ 'url': request.url, 'm': request.method, 'd': request.data, 'h': request.headers, 'ms': request.timeoutMs, 'p': providerName, 'f': responseFormat }, (request.postResultTo ? { 'prt': request.postResultTo } : {})))