@eide/foir-cli 0.5.3 → 0.5.7

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/dist/cli.js CHANGED
@@ -1181,6 +1181,24 @@ var TARGET_FROM_PROTO = {
1181
1181
  [ExtensionTarget.RECORD]: "record",
1182
1182
  [ExtensionTarget.MODEL_LIST]: "model-list"
1183
1183
  };
1184
+ var STRATEGY_STRING_MAP = {
1185
+ CREDENTIAL_STRATEGY_UNSPECIFIED: "none",
1186
+ CREDENTIAL_STRATEGY_OAUTH: "oauth",
1187
+ CREDENTIAL_STRATEGY_API_KEY: "api_key",
1188
+ CREDENTIAL_STRATEGY_SHARED_SECRET: "shared_secret",
1189
+ CREDENTIAL_STRATEGY_SSH_KEY: "ssh_key",
1190
+ CREDENTIAL_STRATEGY_NONE: "none",
1191
+ CREDENTIAL_STRATEGY_MANAGED: "managed"
1192
+ };
1193
+ function resolveStrategy(raw) {
1194
+ if (typeof raw === "number") {
1195
+ return STRATEGY_FROM_PROTO[raw] ?? "none";
1196
+ }
1197
+ if (typeof raw === "string") {
1198
+ return STRATEGY_STRING_MAP[raw] ?? raw.toLowerCase().replace("credential_strategy_", "");
1199
+ }
1200
+ return "none";
1201
+ }
1184
1202
  function integrationConfigToInput(cfg) {
1185
1203
  const sync = {};
1186
1204
  for (const [k, v] of Object.entries(cfg.sync)) {
@@ -1189,13 +1207,11 @@ function integrationConfigToInput(cfg) {
1189
1207
  const out = {
1190
1208
  middleware: { url: cfg.middleware?.url ?? "" },
1191
1209
  credentials: {
1192
- strategy: STRATEGY_FROM_PROTO[cfg.credentials?.strategy ?? CredentialStrategy.UNSPECIFIED] ?? "none"
1210
+ strategy: resolveStrategy(cfg.credentials?.strategy)
1193
1211
  },
1194
1212
  sync
1195
1213
  };
1196
- if (cfg.enabled === false) {
1197
- out.enabled = false;
1198
- }
1214
+ out.enabled = cfg.enabled !== false;
1199
1215
  if (cfg.settings && Object.keys(cfg.settings).length > 0) {
1200
1216
  out.settings = cfg.settings;
1201
1217
  }
@@ -4871,11 +4887,11 @@ async function reconcileConfig(client, configId, manifest) {
4871
4887
  }
4872
4888
  async function reconcileModels(client, configId, models, summary) {
4873
4889
  const existing = await client.models.listModels({ limit: 200 });
4874
- const configOwned = existing.items.filter(
4875
- (m) => m.configId === configId
4890
+ const allByKey = new Map(
4891
+ existing.items.map((m) => [m.key, m])
4876
4892
  );
4877
- const existingByKey = new Map(
4878
- configOwned.map((m) => [m.key, m])
4893
+ const configOwnedByKey = new Map(
4894
+ existing.items.filter((m) => m.configId === configId).map((m) => [m.key, m])
4879
4895
  );
4880
4896
  const manifestKeys = /* @__PURE__ */ new Set();
4881
4897
  for (const m of models) {
@@ -4885,7 +4901,7 @@ async function reconcileModels(client, configId, models, summary) {
4885
4901
  if (m.pluralName) config2.pluralName = m.pluralName;
4886
4902
  if (m.pluralKey) config2.pluralKey = m.pluralKey;
4887
4903
  if (m.description) config2.description = m.description;
4888
- const ex = existingByKey.get(m.key);
4904
+ const ex = allByKey.get(m.key);
4889
4905
  if (ex) {
4890
4906
  await client.models.updateModel({
4891
4907
  id: ex.id,
@@ -4905,7 +4921,7 @@ async function reconcileModels(client, configId, models, summary) {
4905
4921
  summary.models.created++;
4906
4922
  }
4907
4923
  }
4908
- for (const [key, ex] of existingByKey) {
4924
+ for (const [key, ex] of configOwnedByKey) {
4909
4925
  if (!manifestKeys.has(key)) {
4910
4926
  await client.models.deleteModel(
4911
4927
  ex.id
@@ -16,7 +16,11 @@
16
16
  * });
17
17
  * ```
18
18
  */
19
- interface FieldDefinitionInput {
19
+ interface SelectFieldConfig extends Record<string, unknown> {
20
+ optionModelKey: string;
21
+ multiple?: boolean;
22
+ }
23
+ type FieldDefinitionInput = {
20
24
  key: string;
21
25
  type: string;
22
26
  label?: string;
@@ -29,7 +33,11 @@ interface FieldDefinitionInput {
29
33
  storage?: string;
30
34
  templateZone?: string;
31
35
  zoneOrder?: number;
32
- }
36
+ };
37
+ type SelectFieldDefinitionInput = Omit<FieldDefinitionInput, 'type' | 'config'> & {
38
+ type: 'select';
39
+ config: SelectFieldConfig;
40
+ };
33
41
  interface ApplyConfigModelInput {
34
42
  key: string;
35
43
  name: string;
@@ -247,6 +255,8 @@ declare const defineExtension: typeof defineConfig;
247
255
  declare function defineModel(model: ApplyConfigModelInput): ApplyConfigModelInput;
248
256
  /** Define a field with type safety. */
249
257
  declare function defineField(field: FieldDefinitionInput): FieldDefinitionInput;
258
+ /** Define a select field — requires `optionModelKey` pointing to a model whose records become options. */
259
+ declare function defineSelectField(field: SelectFieldDefinitionInput): FieldDefinitionInput;
250
260
  /** Define an operation with type safety. */
251
261
  declare function defineOperation(operation: ApplyConfigOperationInput): ApplyConfigOperationInput;
252
262
  /** Define a segment with type safety. */
@@ -264,4 +274,4 @@ declare function defineIntegration(integration: IntegrationInput): IntegrationIn
264
274
  /** Define an extension declaration. */
265
275
  declare function defineExtensionDeclaration(extension: ExtensionInput): ExtensionInput;
266
276
 
267
- export { type ApplyConfigApiKeyInput, type ApplyConfigAuthProviderInput, type ApplyConfigHookInput, type ApplyConfigInput, type ApplyConfigModelInput, type ApplyConfigOperationInput, type ApplyConfigPlacementInput, type ApplyConfigScheduleInput, type ApplyConfigSegmentInput, type CredentialStrategy, type ExpressionPrecondition, type ExtensionInput, type ExtensionPlacementInput, type ExtensionTarget, type FieldDefinitionInput, type IntegrationCredentialsInput, type IntegrationInput, type IntegrationMiddlewareInput, type IntegrationSyncMappingInput, type ModelSeedFieldInput, type ModelSeedInput, type Precondition, type QuotaRule, type SegmentPrecondition, defineAuthProvider, defineConfig, defineExtension, defineExtensionDeclaration, defineField, defineHook, defineIntegration, defineModel, defineOperation, definePlacement, defineSchedule, defineSegment };
277
+ export { type ApplyConfigApiKeyInput, type ApplyConfigAuthProviderInput, type ApplyConfigHookInput, type ApplyConfigInput, type ApplyConfigModelInput, type ApplyConfigOperationInput, type ApplyConfigPlacementInput, type ApplyConfigScheduleInput, type ApplyConfigSegmentInput, type CredentialStrategy, type ExpressionPrecondition, type ExtensionInput, type ExtensionPlacementInput, type ExtensionTarget, type FieldDefinitionInput, type IntegrationCredentialsInput, type IntegrationInput, type IntegrationMiddlewareInput, type IntegrationSyncMappingInput, type ModelSeedFieldInput, type ModelSeedInput, type Precondition, type QuotaRule, type SegmentPrecondition, type SelectFieldConfig, type SelectFieldDefinitionInput, defineAuthProvider, defineConfig, defineExtension, defineExtensionDeclaration, defineField, defineHook, defineIntegration, defineModel, defineOperation, definePlacement, defineSchedule, defineSegment, defineSelectField };
@@ -9,6 +9,9 @@ function defineModel(model) {
9
9
  function defineField(field) {
10
10
  return field;
11
11
  }
12
+ function defineSelectField(field) {
13
+ return field;
14
+ }
12
15
  function defineOperation(operation) {
13
16
  return operation;
14
17
  }
@@ -45,5 +48,6 @@ export {
45
48
  defineOperation,
46
49
  definePlacement,
47
50
  defineSchedule,
48
- defineSegment
51
+ defineSegment,
52
+ defineSelectField
49
53
  };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@eide/foir-cli",
3
- "version": "0.5.3",
3
+ "version": "0.5.7",
4
4
  "description": "Universal platform CLI for Foir platform",
5
5
  "type": "module",
6
6
  "publishConfig": {