lucid-extension-sdk 0.0.376 → 0.0.378

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/commandtypes.d.ts CHANGED
@@ -862,6 +862,10 @@ export type AddCardIntegrationQuery = {
862
862
  */
863
863
  'sih'?: string;
864
864
  };
865
+ /**
866
+ * Item label phrase
867
+ */
868
+ 'ilp'?: string;
865
869
  } | undefined;
866
870
  };
867
871
  export type AddCardIntegrationResult = undefined;
@@ -0,0 +1,5 @@
1
+ /**
2
+ * Use this to assert that a type check is exhaustive at build-time. There should never be a code path that reaches this function.
3
+ * @param x the value to assert is never reached
4
+ */
5
+ export declare function assertNever(x: never): never;
@@ -0,0 +1,11 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.assertNever = void 0;
4
+ /**
5
+ * Use this to assert that a type check is exhaustive at build-time. There should never be a code path that reaches this function.
6
+ * @param x the value to assert is never reached
7
+ */
8
+ function assertNever(x) {
9
+ throw new Error(`Assertion failed! Expected assertNever to not be called, but it was called with parameter ${JSON.stringify(x)}`);
10
+ }
11
+ exports.assertNever = assertNever;
@@ -36,6 +36,10 @@ interface DependenciesForItemParam {
36
36
  export interface DependenciesForItemsParam {
37
37
  'dfi': DependenciesForItemParam[];
38
38
  }
39
+ export interface DependencyMappingItemLabelPhraseParam {
40
+ 'ci': string;
41
+ 'pk': string;
42
+ }
39
43
  /** @ignore */
40
44
  export interface CustomImportParam {
41
45
  'd': JsonSerializable;
@@ -1,3 +1,4 @@
1
+ import { DataItemProxy } from '../../data/dataitemproxy';
1
2
  interface DependencyManagerEmptyStatePhrasesType {
2
3
  readonly multipleIssueKeyWithNoLink?: string;
3
4
  readonly createLinkInstruction?: string;
@@ -27,5 +28,9 @@ export interface DependencyMappingPhrasesType {
27
28
  cardLabel?: (locale: string, count: number) => string;
28
29
  manager?: DependencyManagerPhrasesType;
29
30
  edit?: DependencyEditPhrasesType;
31
+ /**
32
+ * This function is used to map the dataItemProxy to item label phrase.
33
+ */
34
+ itemLabelPhrase?: (dataItem: DataItemProxy) => string;
30
35
  }
31
36
  export {};
@@ -47,6 +47,7 @@ class LucidCardIntegrationRegistry {
47
47
  const manager = dependencyMappingPhrases.manager;
48
48
  const emptyState = manager === null || manager === void 0 ? void 0 : manager.emptyState;
49
49
  const edit = dependencyMappingPhrases.edit;
50
+ const itemLabelPhrase = dependencyMappingPhrases.itemLabelPhrase;
50
51
  // Strings that appear on the canvas must calculate their locale at runtime,
51
52
  // so all users get canvas content in the same locale
52
53
  const cardLabelActionName = dependencyMappingPhrases.cardLabel
@@ -73,6 +74,15 @@ class LucidCardIntegrationRegistry {
73
74
  return (_a = edit === null || edit === void 0 ? void 0 : edit.selectedIssueHeading) === null || _a === void 0 ? void 0 : _a.call(edit, key);
74
75
  });
75
76
  }
77
+ let itemLabelPhraseActionName = undefined;
78
+ if (itemLabelPhrase) {
79
+ itemLabelPhraseActionName = LucidCardIntegrationRegistry.nextHookName();
80
+ client.registerAction(itemLabelPhraseActionName, ({ 'ci': ci, 'pk': pk }) => {
81
+ const collectionProxy = new collectionproxy_1.CollectionProxy(ci, client);
82
+ const itemProxy = new dataitemproxy_1.DataItemProxy(pk, collectionProxy, client);
83
+ return itemLabelPhrase(itemProxy);
84
+ });
85
+ }
76
86
  serialized['dmp'] = {
77
87
  'ep': dependencyMappingPhrases.entrypoint,
78
88
  'cl': cardLabelActionName,
@@ -105,6 +115,7 @@ class LucidCardIntegrationRegistry {
105
115
  'sih': selectedIssueHeadingActionName,
106
116
  }
107
117
  : undefined,
118
+ 'ilp': itemLabelPhraseActionName,
108
119
  };
109
120
  }
110
121
  if (cardIntegration.importDependencies) {
@@ -38,6 +38,7 @@ export interface MaxLengthConstraintDefinition {
38
38
  value: number;
39
39
  }
40
40
  export type FieldConstraintDefinition = RequiredFieldConstraintDefinition | LockedFieldConstraintDefinition | MinValueFieldConstraintDefinition | MaxValueFieldConstraintDefinition | SingleLineFieldConstraintDefinition | NoWhitespaceFieldConstraintDefinition | UniqueEditFieldConstraintDefinition | MaxLengthConstraintDefinition;
41
+ export declare function createFieldConstraintDefinition(type: FieldConstraintType, value?: number): FieldConstraintDefinition;
41
42
  export declare function minMaxFieldConstraintValidator(val: unknown): val is FieldConstraintType.MIN_VALUE | FieldConstraintType.MAX_VALUE | FieldConstraintType.MAX_LENGTH;
42
43
  export declare const isFieldConstraintDefinition: (x: unknown) => x is {
43
44
  type?: FieldConstraintType | undefined;
@@ -1,10 +1,35 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.parseSchemaDefinition = exports.parseFieldDefinition = exports.serializeSchemaDefinition = exports.serializeFieldDefinition = exports.serializeFieldConstraintDefinition = exports.isFieldConstraintDefinition = exports.minMaxFieldConstraintValidator = void 0;
3
+ exports.parseSchemaDefinition = exports.parseFieldDefinition = exports.serializeSchemaDefinition = exports.serializeFieldDefinition = exports.serializeFieldConstraintDefinition = exports.isFieldConstraintDefinition = exports.minMaxFieldConstraintValidator = exports.createFieldConstraintDefinition = void 0;
4
+ const assertnever_1 = require("../core/assertnever");
4
5
  const checks_1 = require("../core/checks");
5
6
  const fieldtypedefinition_1 = require("../core/data/fieldtypedefinition/fieldtypedefinition");
6
7
  const serializedfielddefinition_1 = require("../core/data/serializedfield/serializedfielddefinition");
7
8
  const validators_1 = require("../core/validators/validators");
9
+ function createFieldConstraintDefinition(type, value) {
10
+ switch (type) {
11
+ case serializedfielddefinition_1.FieldConstraintType.REQUIRED:
12
+ case serializedfielddefinition_1.FieldConstraintType.LOCKED:
13
+ return { type };
14
+ case serializedfielddefinition_1.FieldConstraintType.MIN_VALUE:
15
+ case serializedfielddefinition_1.FieldConstraintType.MAX_VALUE:
16
+ case serializedfielddefinition_1.FieldConstraintType.MAX_LENGTH:
17
+ if (value === undefined) {
18
+ throw new Error('Invalid constraint value');
19
+ }
20
+ return { type, value };
21
+ case serializedfielddefinition_1.FieldConstraintType.SINGLE_LINE_ONLY:
22
+ case serializedfielddefinition_1.FieldConstraintType.NO_WHITESPACE:
23
+ case serializedfielddefinition_1.FieldConstraintType.UNIQUE_EDIT:
24
+ if (value !== undefined) {
25
+ throw new Error('Invalid constraint value');
26
+ }
27
+ return { type };
28
+ default:
29
+ (0, assertnever_1.assertNever)(type);
30
+ }
31
+ }
32
+ exports.createFieldConstraintDefinition = createFieldConstraintDefinition;
8
33
  function minMaxFieldConstraintValidator(val) {
9
34
  return (val === serializedfielddefinition_1.FieldConstraintType.MIN_VALUE ||
10
35
  val === serializedfielddefinition_1.FieldConstraintType.MAX_VALUE ||
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "lucid-extension-sdk",
3
- "version": "0.0.376",
3
+ "version": "0.0.378",
4
4
  "description": "Utility classes for writing Lucid Software editor extensions",
5
5
  "main": "index.js",
6
6
  "types": "index.d.ts",