@uniformdev/cli 20.29.2-alpha.6 → 20.29.2-alpha.8

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.
Files changed (2) hide show
  1. package/dist/index.mjs +562 -564
  2. package/package.json +9 -9
package/dist/index.mjs CHANGED
@@ -24,7 +24,7 @@ import yargs35 from "yargs";
24
24
  import { hideBin } from "yargs/helpers";
25
25
 
26
26
  // src/commands/canvas/index.ts
27
- import yargs18 from "yargs";
27
+ import yargs17 from "yargs";
28
28
 
29
29
  // src/commands/canvas/commands/asset.ts
30
30
  import yargs from "yargs";
@@ -6507,181 +6507,30 @@ var PromptModule = {
6507
6507
  }
6508
6508
  };
6509
6509
 
6510
- // src/commands/canvas/commands/webhooks.ts
6510
+ // src/commands/canvas/commands/workflow.ts
6511
6511
  import yargs16 from "yargs";
6512
6512
 
6513
- // src/webhooksClient.ts
6514
- import { ApiClient } from "@uniformdev/context/api";
6515
- import PQueue3 from "p-queue";
6516
- import { Svix } from "svix";
6517
- import { z } from "zod";
6518
- var WEBHOOKS_DASHBOARD_BASE_PATH = "/api/v1/svix-dashboard";
6519
- var WebhooksClient = class extends ApiClient {
6520
- constructor(options) {
6521
- super(options);
6522
- }
6523
- async getToken() {
6524
- const { projectId } = this.options;
6525
- const { dashboard_url: dashboardUrl } = await this.apiClient(
6526
- this.createUrl(WEBHOOKS_DASHBOARD_BASE_PATH, {
6527
- projectId
6528
- })
6529
- );
6530
- if (!dashboardUrl) {
6531
- throw new Error("Webhooks are not activated for this project");
6532
- }
6533
- const key = dashboardUrl.split("key=")[1];
6534
- if (!key) {
6535
- throw new Error("Failed to get webhooks token");
6536
- }
6537
- const keySchema = z.object({
6538
- appId: z.string(),
6539
- oneTimeToken: z.string(),
6540
- region: z.enum(["us", "eu"])
6541
- });
6542
- const { appId, oneTimeToken, region } = keySchema.parse(JSON.parse(atob(key)));
6543
- const tokenSchema = z.object({
6544
- token: z.string()
6545
- });
6546
- const tokenResponse = await fetch(`https://api.${region}.svix.com/api/v1/auth/one-time-token`, {
6547
- method: "POST",
6548
- body: JSON.stringify({
6549
- oneTimeToken
6550
- }),
6551
- headers: {
6552
- "content-type": "application/json"
6553
- }
6554
- });
6555
- const tokenData = await tokenResponse.json();
6556
- const { token: svixToken } = tokenSchema.parse(tokenData);
6557
- return {
6558
- appId,
6559
- token: svixToken
6560
- };
6561
- }
6562
- async get() {
6563
- const webhooksAPIQueue = new PQueue3({ concurrency: 10 });
6564
- const { appId, token } = await this.getToken();
6565
- const svix = new Svix(token);
6566
- const getEndpoints = async ({
6567
- iterator,
6568
- endpoints: endpoints2 = []
6569
- } = {
6570
- endpoints: []
6571
- }) => {
6572
- const {
6573
- data,
6574
- done,
6575
- iterator: nextIterator
6576
- } = await webhooksAPIQueue.add(
6577
- async () => svix.endpoint.list(appId, {
6578
- limit: 100,
6579
- iterator
6580
- }),
6581
- {
6582
- throwOnTimeout: true
6583
- }
6584
- );
6585
- if (!done && nextIterator) {
6586
- return getEndpoints({
6587
- iterator: nextIterator,
6588
- endpoints: [...endpoints2, ...data]
6589
- });
6590
- }
6591
- return [...endpoints2, ...data];
6592
- };
6593
- const endpoints = await getEndpoints();
6594
- return Promise.all(
6595
- endpoints.map(async (endpoint) => {
6596
- const headers = await webhooksAPIQueue.add(async () => svix.endpoint.getHeaders(appId, endpoint.id), {
6597
- throwOnTimeout: true
6598
- }).catch(() => null);
6599
- const transformation = await webhooksAPIQueue.add(async () => svix.endpoint.transformationGet(appId, endpoint.id), {
6600
- throwOnTimeout: true
6601
- }).catch(() => null);
6602
- return {
6603
- endpoint,
6604
- headers,
6605
- transformation
6606
- };
6607
- })
6608
- );
6609
- }
6610
- async put(webhook) {
6611
- const { appId, token } = await this.getToken();
6612
- const svix = new Svix(token);
6613
- let existingEndpoint = null;
6614
- try {
6615
- existingEndpoint = await svix.endpoint.get(appId, webhook.endpoint.id);
6616
- } catch {
6617
- }
6618
- if (existingEndpoint) {
6619
- existingEndpoint = await svix.endpoint.patch(appId, webhook.endpoint.id, {
6620
- ...webhook.endpoint,
6621
- uid: existingEndpoint.uid
6622
- });
6623
- } else {
6624
- existingEndpoint = await svix.endpoint.create(appId, {
6625
- ...webhook.endpoint,
6626
- uid: webhook.endpoint.id
6627
- });
6628
- }
6629
- if (webhook.headers) {
6630
- await svix.endpoint.updateHeaders(appId, existingEndpoint.id, webhook.headers);
6631
- }
6632
- if (webhook.transformation) {
6633
- await svix.endpoint.transformationPartialUpdate(appId, existingEndpoint.id, webhook.transformation);
6634
- }
6635
- return existingEndpoint;
6636
- }
6637
- async delete(endpointId) {
6638
- const { appId, token } = await this.getToken();
6639
- const svix = new Svix(token);
6640
- await svix.endpoint.delete(appId, endpointId);
6641
- }
6642
- };
6643
-
6644
- // src/commands/canvas/commands/webhook/_util.ts
6645
- var selectIdentifier7 = (webhook) => webhook.endpoint.uid ?? webhook.endpoint.id;
6646
- var selectDisplayName7 = (webhook) => `${webhook.endpoint.url} (pid: ${webhook.endpoint.uid ?? webhook.endpoint.id})`;
6647
- var getWebhooksClient = (options) => new WebhooksClient({ ...options, bypassCache: true, limitPolicy: cliLimitPolicy });
6648
- var compareWebhooks = (source, target) => {
6649
- const { endpoint: sourceEndpoint, ...sourceWithoutEndpoint } = source.object;
6650
- const { endpoint: targetEndpoint, ...targetWithoutEndpoint } = target.object;
6651
- const {
6652
- id: sourceId,
6653
- uid: sourceUid,
6654
- version: sourceVersion,
6655
- createdAt: sourceCreatedAt,
6656
- updatedAt: sourceUpdatedAt,
6657
- ...sourceToCompare
6658
- } = sourceEndpoint;
6659
- const {
6660
- id: targetId,
6661
- uid: targetUid,
6662
- version: targetVersion,
6663
- createdAt: targetCreatedAt,
6664
- updatedAt: targetUpdatedAt,
6665
- ...targetToCompare
6666
- } = targetEndpoint;
6667
- return serializedDequal(
6668
- { ...sourceWithoutEndpoint, endpoint: sourceToCompare },
6669
- { ...targetWithoutEndpoint, endpoint: targetToCompare }
6670
- );
6671
- };
6513
+ // src/commands/canvas/commands/workflow/_util.ts
6514
+ import { WorkflowClient } from "@uniformdev/canvas";
6515
+ var selectIdentifier7 = (workflow) => workflow.id;
6516
+ var selectDisplayName7 = (workflow) => `${workflow.name} (pid: ${workflow.id})`;
6517
+ var getWorkflowClient = (options) => new WorkflowClient({ ...options, bypassCache: true, limitPolicy: cliLimitPolicy });
6672
6518
 
6673
- // src/commands/canvas/webhookEngineDataSource.ts
6674
- function createWebhookEngineDataSource({
6519
+ // src/commands/canvas/workflowEngineDataSource.ts
6520
+ function createWorkflowEngineDataSource({
6675
6521
  client
6676
6522
  }) {
6677
6523
  async function* getObjects() {
6678
- const webhooks = await client.get();
6679
- for await (const webhook of webhooks) {
6524
+ const workflows = paginateAsync(async () => (await client.get()).results, {
6525
+ pageSize: 100
6526
+ });
6527
+ for await (const workflow of workflows) {
6528
+ const { modified, modifiedBy, created, createdBy, ...workflowWithoutStatistics } = workflow;
6680
6529
  const result = {
6681
- id: selectIdentifier7(webhook),
6682
- displayName: selectDisplayName7(webhook),
6683
- providerId: webhook.endpoint.id,
6684
- object: webhook
6530
+ id: selectIdentifier7(workflow),
6531
+ displayName: selectDisplayName7(workflow),
6532
+ providerId: workflow.id,
6533
+ object: workflowWithoutStatistics
6685
6534
  };
6686
6535
  yield result;
6687
6536
  }
@@ -6690,18 +6539,18 @@ function createWebhookEngineDataSource({
6690
6539
  name: "Uniform API",
6691
6540
  objects: getObjects(),
6692
6541
  deleteObject: async (providerId) => {
6693
- await client.delete(providerId);
6542
+ await client.remove({ workflowId: providerId });
6694
6543
  },
6695
6544
  writeObject: async (object) => {
6696
- await client.put(object.object);
6545
+ await client.upsert({ workflow: object.object });
6697
6546
  }
6698
6547
  };
6699
6548
  }
6700
6549
 
6701
- // src/commands/canvas/commands/webhook/pull.ts
6702
- var WebhookPullModule = {
6550
+ // src/commands/canvas/commands/workflow/pull.ts
6551
+ var WorkflowPullModule = {
6703
6552
  command: "pull <directory>",
6704
- describe: "Pulls all webhooks to local files in a directory",
6553
+ describe: "Pulls all workflows to local files in a directory",
6705
6554
  builder: (yargs36) => withConfiguration(
6706
6555
  withApiOptions(
6707
6556
  withDebugOptions(
@@ -6742,19 +6591,19 @@ var WebhookPullModule = {
6742
6591
  verbose
6743
6592
  }) => {
6744
6593
  const fetch2 = nodeFetchProxy(proxy, verbose);
6745
- const client = getWebhooksClient({ apiKey, apiHost, fetch: fetch2, projectId });
6746
- const source = createWebhookEngineDataSource({ client });
6594
+ const client = getWorkflowClient({ apiKey, apiHost, fetch: fetch2, projectId });
6595
+ const source = createWorkflowEngineDataSource({ client });
6747
6596
  let target;
6748
6597
  const isPackage = isPathAPackageFile(directory);
6749
6598
  if (isPackage) {
6750
6599
  const packageContents = readCanvasPackage(directory, false, verbose);
6751
6600
  target = await createArraySyncEngineDataSource({
6752
6601
  name: `Package file ${directory}`,
6753
- objects: packageContents.webhooks ?? [],
6602
+ objects: packageContents.workflows ?? [],
6754
6603
  selectIdentifier: selectIdentifier7,
6755
6604
  selectDisplayName: selectDisplayName7,
6756
6605
  onSyncComplete: async (_, synced) => {
6757
- packageContents.webhooks = synced;
6606
+ packageContents.workflows = synced;
6758
6607
  writeCanvasPackage(directory, packageContents);
6759
6608
  }
6760
6609
  });
@@ -6773,16 +6622,15 @@ var WebhookPullModule = {
6773
6622
  mode,
6774
6623
  whatIf,
6775
6624
  allowEmptySource: allowEmptySource ?? true,
6776
- log: createSyncEngineConsoleLogger({ diffMode }),
6777
- compareContents: compareWebhooks
6625
+ log: createSyncEngineConsoleLogger({ diffMode })
6778
6626
  });
6779
6627
  }
6780
6628
  };
6781
6629
 
6782
- // src/commands/canvas/commands/webhook/push.ts
6783
- var WebhookPushModule = {
6630
+ // src/commands/canvas/commands/workflow/push.ts
6631
+ var WorkflowPushModule = {
6784
6632
  command: "push <directory>",
6785
- describe: "Pushes all webhooks from files in a directory to Uniform Canvas",
6633
+ describe: "Pushes all workflows from files in a directory to Uniform Canvas",
6786
6634
  builder: (yargs36) => withConfiguration(
6787
6635
  withDebugOptions(
6788
6636
  withApiOptions(
@@ -6816,14 +6664,14 @@ var WebhookPushModule = {
6816
6664
  verbose
6817
6665
  }) => {
6818
6666
  const fetch2 = nodeFetchProxy(proxy, verbose);
6819
- const client = getWebhooksClient({ apiKey, apiHost, fetch: fetch2, projectId });
6667
+ const client = getWorkflowClient({ apiKey, apiHost, fetch: fetch2, projectId });
6820
6668
  let source;
6821
6669
  const isPackage = isPathAPackageFile(directory);
6822
6670
  if (isPackage) {
6823
6671
  const packageContents = readCanvasPackage(directory, true, verbose);
6824
6672
  source = await createArraySyncEngineDataSource({
6825
6673
  name: `Package file ${directory}`,
6826
- objects: packageContents.webhooks ?? [],
6674
+ objects: packageContents.workflows ?? [],
6827
6675
  selectIdentifier: selectIdentifier7,
6828
6676
  selectDisplayName: selectDisplayName7
6829
6677
  });
@@ -6835,250 +6683,50 @@ var WebhookPushModule = {
6835
6683
  verbose
6836
6684
  });
6837
6685
  }
6838
- const target = createWebhookEngineDataSource({ client });
6686
+ const target = createWorkflowEngineDataSource({ client });
6839
6687
  await syncEngine({
6840
6688
  source,
6841
6689
  target,
6842
6690
  mode,
6843
6691
  whatIf,
6844
6692
  allowEmptySource,
6845
- log: createSyncEngineConsoleLogger({ diffMode }),
6846
- compareContents: compareWebhooks
6693
+ log: createSyncEngineConsoleLogger({ diffMode })
6847
6694
  });
6848
6695
  }
6849
6696
  };
6850
6697
 
6851
- // src/commands/canvas/commands/webhooks.ts
6852
- var WebhookModule = {
6853
- command: "webhook <command>",
6854
- aliases: ["wh"],
6855
- describe: "Commands for Canvas webhooks",
6856
- builder: (yargs36) => yargs36.command(WebhookPullModule).command(WebhookPushModule).demandCommand(),
6698
+ // src/commands/canvas/commands/workflow.ts
6699
+ var WorkflowModule = {
6700
+ command: "workflow <command>",
6701
+ aliases: ["wf"],
6702
+ describe: "Commands for Canvas workflows",
6703
+ builder: (yargs36) => yargs36.command(WorkflowPullModule).command(WorkflowPushModule).demandCommand(),
6857
6704
  handler: () => {
6858
6705
  yargs16.help();
6859
6706
  }
6860
6707
  };
6861
6708
 
6862
- // src/commands/canvas/commands/workflow.ts
6863
- import yargs17 from "yargs";
6709
+ // src/commands/canvas/index.ts
6710
+ var CanvasCommand = {
6711
+ command: "canvas <command>",
6712
+ aliases: ["cv", "pm", "presentation"],
6713
+ describe: "Uniform Canvas commands",
6714
+ builder: (yargs36) => yargs36.command(CompositionModule).command(ComponentModule).command(DataTypeModule).command(DataSourceModule).command(CategoryModule).command(ComponentPatternModule).command(CompositionPatternModule).command(ContentTypeModule).command(EntryModule).command(EntryPatternModule).command(PromptModule).command(AssetModule).command(LocaleModule).command(WorkflowModule).command(PreviewUrlModule).command(PreviewViewportModule).demandCommand(),
6715
+ handler: () => {
6716
+ yargs17.showHelp();
6717
+ }
6718
+ };
6864
6719
 
6865
- // src/commands/canvas/commands/workflow/_util.ts
6866
- import { WorkflowClient } from "@uniformdev/canvas";
6867
- var selectIdentifier8 = (workflow) => workflow.id;
6868
- var selectDisplayName8 = (workflow) => `${workflow.name} (pid: ${workflow.id})`;
6869
- var getWorkflowClient = (options) => new WorkflowClient({ ...options, bypassCache: true, limitPolicy: cliLimitPolicy });
6720
+ // src/commands/context/index.ts
6721
+ import yargs24 from "yargs";
6870
6722
 
6871
- // src/commands/canvas/workflowEngineDataSource.ts
6872
- function createWorkflowEngineDataSource({
6873
- client
6874
- }) {
6875
- async function* getObjects() {
6876
- const workflows = paginateAsync(async () => (await client.get()).results, {
6877
- pageSize: 100
6878
- });
6879
- for await (const workflow of workflows) {
6880
- const { modified, modifiedBy, created, createdBy, ...workflowWithoutStatistics } = workflow;
6881
- const result = {
6882
- id: selectIdentifier8(workflow),
6883
- displayName: selectDisplayName8(workflow),
6884
- providerId: workflow.id,
6885
- object: workflowWithoutStatistics
6886
- };
6887
- yield result;
6888
- }
6889
- }
6890
- return {
6891
- name: "Uniform API",
6892
- objects: getObjects(),
6893
- deleteObject: async (providerId) => {
6894
- await client.remove({ workflowId: providerId });
6895
- },
6896
- writeObject: async (object) => {
6897
- await client.upsert({ workflow: object.object });
6898
- }
6899
- };
6900
- }
6901
-
6902
- // src/commands/canvas/commands/workflow/pull.ts
6903
- var WorkflowPullModule = {
6904
- command: "pull <directory>",
6905
- describe: "Pulls all workflows to local files in a directory",
6906
- builder: (yargs36) => withConfiguration(
6907
- withApiOptions(
6908
- withDebugOptions(
6909
- withProjectOptions(
6910
- withDiffOptions(
6911
- yargs36.positional("directory", {
6912
- describe: "Directory to save to. If a filename ending in yaml or json is used, a package file will be created instead of files in the directory.",
6913
- type: "string"
6914
- }).option("format", {
6915
- alias: ["f"],
6916
- describe: "Output format",
6917
- default: "yaml",
6918
- choices: ["yaml", "json"],
6919
- type: "string"
6920
- }).option("mode", {
6921
- alias: ["m"],
6922
- describe: 'What kind of changes can be made. "create" = create new files, update nothing. "createOrUpdate" = create new files, update existing, delete nothing. "mirror" = create, update, and delete to mirror state',
6923
- choices: ["create", "createOrUpdate", "mirror"],
6924
- default: "mirror",
6925
- type: "string"
6926
- })
6927
- )
6928
- )
6929
- )
6930
- )
6931
- ),
6932
- handler: async ({
6933
- apiHost,
6934
- apiKey,
6935
- proxy,
6936
- directory,
6937
- format,
6938
- mode,
6939
- whatIf,
6940
- project: projectId,
6941
- diff: diffMode,
6942
- allowEmptySource,
6943
- verbose
6944
- }) => {
6945
- const fetch2 = nodeFetchProxy(proxy, verbose);
6946
- const client = getWorkflowClient({ apiKey, apiHost, fetch: fetch2, projectId });
6947
- const source = createWorkflowEngineDataSource({ client });
6948
- let target;
6949
- const isPackage = isPathAPackageFile(directory);
6950
- if (isPackage) {
6951
- const packageContents = readCanvasPackage(directory, false, verbose);
6952
- target = await createArraySyncEngineDataSource({
6953
- name: `Package file ${directory}`,
6954
- objects: packageContents.workflows ?? [],
6955
- selectIdentifier: selectIdentifier8,
6956
- selectDisplayName: selectDisplayName8,
6957
- onSyncComplete: async (_, synced) => {
6958
- packageContents.workflows = synced;
6959
- writeCanvasPackage(directory, packageContents);
6960
- }
6961
- });
6962
- } else {
6963
- target = await createFileSyncEngineDataSource({
6964
- directory,
6965
- selectIdentifier: selectIdentifier8,
6966
- selectDisplayName: selectDisplayName8,
6967
- format,
6968
- verbose
6969
- });
6970
- }
6971
- await syncEngine({
6972
- source,
6973
- target,
6974
- mode,
6975
- whatIf,
6976
- allowEmptySource: allowEmptySource ?? true,
6977
- log: createSyncEngineConsoleLogger({ diffMode })
6978
- });
6979
- }
6980
- };
6981
-
6982
- // src/commands/canvas/commands/workflow/push.ts
6983
- var WorkflowPushModule = {
6984
- command: "push <directory>",
6985
- describe: "Pushes all workflows from files in a directory to Uniform Canvas",
6986
- builder: (yargs36) => withConfiguration(
6987
- withDebugOptions(
6988
- withApiOptions(
6989
- withProjectOptions(
6990
- withDiffOptions(
6991
- yargs36.positional("directory", {
6992
- describe: "Directory to read from. If a filename is used, a package will be read instead.",
6993
- type: "string"
6994
- }).option("mode", {
6995
- alias: ["m"],
6996
- describe: 'What kind of changes can be made. "create" = create new, update nothing. "createOrUpdate" = create new, update existing, delete nothing. "mirror" = create, update, and delete',
6997
- choices: ["create", "createOrUpdate", "mirror"],
6998
- default: "mirror",
6999
- type: "string"
7000
- })
7001
- )
7002
- )
7003
- )
7004
- )
7005
- ),
7006
- handler: async ({
7007
- apiHost,
7008
- apiKey,
7009
- proxy,
7010
- directory,
7011
- mode,
7012
- whatIf,
7013
- project: projectId,
7014
- diff: diffMode,
7015
- allowEmptySource,
7016
- verbose
7017
- }) => {
7018
- const fetch2 = nodeFetchProxy(proxy, verbose);
7019
- const client = getWorkflowClient({ apiKey, apiHost, fetch: fetch2, projectId });
7020
- let source;
7021
- const isPackage = isPathAPackageFile(directory);
7022
- if (isPackage) {
7023
- const packageContents = readCanvasPackage(directory, true, verbose);
7024
- source = await createArraySyncEngineDataSource({
7025
- name: `Package file ${directory}`,
7026
- objects: packageContents.workflows ?? [],
7027
- selectIdentifier: selectIdentifier8,
7028
- selectDisplayName: selectDisplayName8
7029
- });
7030
- } else {
7031
- source = await createFileSyncEngineDataSource({
7032
- directory,
7033
- selectIdentifier: selectIdentifier8,
7034
- selectDisplayName: selectDisplayName8,
7035
- verbose
7036
- });
7037
- }
7038
- const target = createWorkflowEngineDataSource({ client });
7039
- await syncEngine({
7040
- source,
7041
- target,
7042
- mode,
7043
- whatIf,
7044
- allowEmptySource,
7045
- log: createSyncEngineConsoleLogger({ diffMode })
7046
- });
7047
- }
7048
- };
7049
-
7050
- // src/commands/canvas/commands/workflow.ts
7051
- var WorkflowModule = {
7052
- command: "workflow <command>",
7053
- aliases: ["wf"],
7054
- describe: "Commands for Canvas workflows",
7055
- builder: (yargs36) => yargs36.command(WorkflowPullModule).command(WorkflowPushModule).demandCommand(),
7056
- handler: () => {
7057
- yargs17.help();
7058
- }
7059
- };
7060
-
7061
- // src/commands/canvas/index.ts
7062
- var CanvasCommand = {
7063
- command: "canvas <command>",
7064
- aliases: ["cv", "pm", "presentation"],
7065
- describe: "Uniform Canvas commands",
7066
- builder: (yargs36) => yargs36.command(CompositionModule).command(ComponentModule).command(DataTypeModule).command(DataSourceModule).command(CategoryModule).command(ComponentPatternModule).command(CompositionPatternModule).command(ContentTypeModule).command(EntryModule).command(EntryPatternModule).command(PromptModule).command(AssetModule).command(LocaleModule).command(WorkflowModule).command(WebhookModule).command(PreviewUrlModule).command(PreviewViewportModule).demandCommand(),
7067
- handler: () => {
7068
- yargs18.showHelp();
7069
- }
7070
- };
7071
-
7072
- // src/commands/context/index.ts
7073
- import yargs25 from "yargs";
7074
-
7075
- // src/commands/context/commands/aggregate.ts
7076
- import yargs19 from "yargs";
6723
+ // src/commands/context/commands/aggregate.ts
6724
+ import yargs18 from "yargs";
7077
6725
 
7078
6726
  // src/commands/context/commands/aggregate/_util.ts
7079
6727
  import { AggregateClient } from "@uniformdev/context/api";
7080
- var selectIdentifier9 = (source) => source.id;
7081
- var selectDisplayName9 = (source) => `${source.name} (pid: ${source.id})`;
6728
+ var selectIdentifier8 = (source) => source.id;
6729
+ var selectDisplayName8 = (source) => `${source.name} (pid: ${source.id})`;
7082
6730
  var getAggregateClient = (options) => new AggregateClient({ ...options, bypassCache: true, limitPolicy: cliLimitPolicy });
7083
6731
 
7084
6732
  // src/commands/context/commands/aggregate/get.ts
@@ -7130,8 +6778,8 @@ function createAggregateEngineDataSource({
7130
6778
  const aggregates = (await client.get({ type })).aggregates;
7131
6779
  for await (const def of aggregates) {
7132
6780
  const result = {
7133
- id: selectIdentifier9(def),
7134
- displayName: selectDisplayName9(def),
6781
+ id: selectIdentifier8(def),
6782
+ displayName: selectDisplayName8(def),
7135
6783
  providerId: def.id,
7136
6784
  object: def
7137
6785
  };
@@ -7224,8 +6872,8 @@ var AggregatePullModule = {
7224
6872
  target = await createArraySyncEngineDataSource({
7225
6873
  name: `Package file ${directory}`,
7226
6874
  objects: packageContents.aggregates ?? [],
7227
- selectIdentifier: selectIdentifier9,
7228
- selectDisplayName: selectDisplayName9,
6875
+ selectIdentifier: selectIdentifier8,
6876
+ selectDisplayName: selectDisplayName8,
7229
6877
  onSyncComplete: async (_, synced) => {
7230
6878
  packageContents.aggregates = synced;
7231
6879
  writeContextPackage(directory, packageContents);
@@ -7234,8 +6882,8 @@ var AggregatePullModule = {
7234
6882
  } else {
7235
6883
  target = await createFileSyncEngineDataSource({
7236
6884
  directory,
7237
- selectIdentifier: selectIdentifier9,
7238
- selectDisplayName: selectDisplayName9,
6885
+ selectIdentifier: selectIdentifier8,
6886
+ selectDisplayName: selectDisplayName8,
7239
6887
  format,
7240
6888
  verbose
7241
6889
  });
@@ -7296,14 +6944,14 @@ var AggregatePushModule = {
7296
6944
  source = await createArraySyncEngineDataSource({
7297
6945
  name: `Package file ${directory}`,
7298
6946
  objects: packageContents.aggregates ?? [],
7299
- selectIdentifier: selectIdentifier9,
7300
- selectDisplayName: selectDisplayName9
6947
+ selectIdentifier: selectIdentifier8,
6948
+ selectDisplayName: selectDisplayName8
7301
6949
  });
7302
6950
  } else {
7303
6951
  source = await createFileSyncEngineDataSource({
7304
6952
  directory,
7305
- selectIdentifier: selectIdentifier9,
7306
- selectDisplayName: selectDisplayName9,
6953
+ selectIdentifier: selectIdentifier8,
6954
+ selectDisplayName: selectDisplayName8,
7307
6955
  verbose
7308
6956
  });
7309
6957
  }
@@ -7366,17 +7014,17 @@ var AggregateModule = {
7366
7014
  describe: "Commands for Context aggregates (intents, audiences)",
7367
7015
  builder: (yargs36) => yargs36.command(AggregatePullModule).command(AggregatePushModule).command(AggregateGetModule).command(AggregateRemoveModule).command(AggregateListModule).command(AggregateUpdateModule).demandCommand(),
7368
7016
  handler: () => {
7369
- yargs19.help();
7017
+ yargs18.help();
7370
7018
  }
7371
7019
  };
7372
7020
 
7373
7021
  // src/commands/context/commands/enrichment.ts
7374
- import yargs20 from "yargs";
7022
+ import yargs19 from "yargs";
7375
7023
 
7376
7024
  // src/commands/context/commands/enrichment/_util.ts
7377
7025
  import { UncachedEnrichmentClient } from "@uniformdev/context/api";
7378
- var selectIdentifier10 = (source) => source.id;
7379
- var selectDisplayName10 = (source) => `${source.name} (pid: ${source.id})`;
7026
+ var selectIdentifier9 = (source) => source.id;
7027
+ var selectDisplayName9 = (source) => `${source.name} (pid: ${source.id})`;
7380
7028
  function getEnrichmentClient(options) {
7381
7029
  return new UncachedEnrichmentClient({ ...options, limitPolicy: cliLimitPolicy });
7382
7030
  }
@@ -7429,8 +7077,8 @@ function createEnrichmentEngineDataSource({
7429
7077
  const enrichments = (await client.get()).enrichments;
7430
7078
  for await (const def of enrichments) {
7431
7079
  const result = {
7432
- id: selectIdentifier10(def),
7433
- displayName: selectDisplayName10(def),
7080
+ id: selectIdentifier9(def),
7081
+ displayName: selectDisplayName9(def),
7434
7082
  providerId: def.id,
7435
7083
  object: def
7436
7084
  };
@@ -7556,8 +7204,8 @@ var EnrichmentPullModule = {
7556
7204
  target = await createArraySyncEngineDataSource({
7557
7205
  name: `Package file ${directory}`,
7558
7206
  objects: packageContents.enrichments ?? [],
7559
- selectIdentifier: selectIdentifier10,
7560
- selectDisplayName: selectDisplayName10,
7207
+ selectIdentifier: selectIdentifier9,
7208
+ selectDisplayName: selectDisplayName9,
7561
7209
  onSyncComplete: async (_, synced) => {
7562
7210
  packageContents.enrichments = synced;
7563
7211
  writeContextPackage(directory, packageContents);
@@ -7566,8 +7214,8 @@ var EnrichmentPullModule = {
7566
7214
  } else {
7567
7215
  target = await createFileSyncEngineDataSource({
7568
7216
  directory,
7569
- selectIdentifier: selectIdentifier10,
7570
- selectDisplayName: selectDisplayName10,
7217
+ selectIdentifier: selectIdentifier9,
7218
+ selectDisplayName: selectDisplayName9,
7571
7219
  format,
7572
7220
  verbose
7573
7221
  });
@@ -7626,14 +7274,14 @@ var EnrichmentPushModule = {
7626
7274
  source = await createArraySyncEngineDataSource({
7627
7275
  name: `Package file ${directory}`,
7628
7276
  objects: packageContents.enrichments ?? [],
7629
- selectIdentifier: selectIdentifier10,
7630
- selectDisplayName: selectDisplayName10
7277
+ selectIdentifier: selectIdentifier9,
7278
+ selectDisplayName: selectDisplayName9
7631
7279
  });
7632
7280
  } else {
7633
7281
  source = await createFileSyncEngineDataSource({
7634
7282
  directory,
7635
- selectIdentifier: selectIdentifier10,
7636
- selectDisplayName: selectDisplayName10,
7283
+ selectIdentifier: selectIdentifier9,
7284
+ selectDisplayName: selectDisplayName9,
7637
7285
  verbose
7638
7286
  });
7639
7287
  }
@@ -7675,12 +7323,12 @@ var EnrichmentModule = {
7675
7323
  describe: "Commands for Context enrichments",
7676
7324
  builder: (yargs36) => yargs36.command(EnrichmentPullModule).command(EnrichmentPushModule).command(EnrichmentGetModule).command(EnrichmentRemoveModule).command(EnrichmentListModule).demandCommand(),
7677
7325
  handler: () => {
7678
- yargs20.help();
7326
+ yargs19.help();
7679
7327
  }
7680
7328
  };
7681
7329
 
7682
7330
  // src/commands/context/commands/manifest.ts
7683
- import yargs21 from "yargs";
7331
+ import yargs20 from "yargs";
7684
7332
 
7685
7333
  // src/commands/context/commands/manifest/get.ts
7686
7334
  import { ApiClientError as ApiClientError2, UncachedManifestClient } from "@uniformdev/context/api";
@@ -7791,12 +7439,12 @@ var ManifestModule = {
7791
7439
  aliases: ["man"],
7792
7440
  builder: (yargs36) => yargs36.command(ManifestGetModule).command(ManifestPublishModule).demandCommand(),
7793
7441
  handler: () => {
7794
- yargs21.help();
7442
+ yargs20.help();
7795
7443
  }
7796
7444
  };
7797
7445
 
7798
7446
  // src/commands/context/commands/quirk.ts
7799
- import yargs22 from "yargs";
7447
+ import yargs21 from "yargs";
7800
7448
 
7801
7449
  // src/commands/context/commands/quirk/get.ts
7802
7450
  import { UncachedQuirkClient } from "@uniformdev/context/api";
@@ -7856,8 +7504,8 @@ var QuirkListModule = {
7856
7504
  import { UncachedQuirkClient as UncachedQuirkClient3 } from "@uniformdev/context/api";
7857
7505
 
7858
7506
  // src/commands/context/commands/quirk/_util.ts
7859
- var selectIdentifier11 = (source) => source.id;
7860
- var selectDisplayName11 = (source) => `${source.name} (pid: ${source.id})`;
7507
+ var selectIdentifier10 = (source) => source.id;
7508
+ var selectDisplayName10 = (source) => `${source.name} (pid: ${source.id})`;
7861
7509
 
7862
7510
  // src/commands/context/quirkEngineDataSource.ts
7863
7511
  function createQuirkEngineDataSource({
@@ -7867,8 +7515,8 @@ function createQuirkEngineDataSource({
7867
7515
  const quirks = (await client.get({ withIntegrations: false })).quirks;
7868
7516
  for await (const def of quirks) {
7869
7517
  const result = {
7870
- id: selectIdentifier11(def),
7871
- displayName: selectDisplayName11(def),
7518
+ id: selectIdentifier10(def),
7519
+ displayName: selectDisplayName10(def),
7872
7520
  providerId: def.id,
7873
7521
  object: def
7874
7522
  };
@@ -7942,8 +7590,8 @@ var QuirkPullModule = {
7942
7590
  target = await createArraySyncEngineDataSource({
7943
7591
  name: `Package file ${directory}`,
7944
7592
  objects: packageContents.quirks ?? [],
7945
- selectIdentifier: selectIdentifier11,
7946
- selectDisplayName: selectDisplayName11,
7593
+ selectIdentifier: selectIdentifier10,
7594
+ selectDisplayName: selectDisplayName10,
7947
7595
  onSyncComplete: async (_, synced) => {
7948
7596
  packageContents.quirks = synced;
7949
7597
  writeContextPackage(directory, packageContents);
@@ -7952,8 +7600,8 @@ var QuirkPullModule = {
7952
7600
  } else {
7953
7601
  target = await createFileSyncEngineDataSource({
7954
7602
  directory,
7955
- selectIdentifier: selectIdentifier11,
7956
- selectDisplayName: selectDisplayName11,
7603
+ selectIdentifier: selectIdentifier10,
7604
+ selectDisplayName: selectDisplayName10,
7957
7605
  format,
7958
7606
  verbose
7959
7607
  });
@@ -8015,14 +7663,14 @@ var QuirkPushModule = {
8015
7663
  source = await createArraySyncEngineDataSource({
8016
7664
  name: `Package file ${directory}`,
8017
7665
  objects: packageContents.quirks ?? [],
8018
- selectIdentifier: selectIdentifier11,
8019
- selectDisplayName: selectDisplayName11
7666
+ selectIdentifier: selectIdentifier10,
7667
+ selectDisplayName: selectDisplayName10
8020
7668
  });
8021
7669
  } else {
8022
7670
  source = await createFileSyncEngineDataSource({
8023
7671
  directory,
8024
- selectIdentifier: selectIdentifier11,
8025
- selectDisplayName: selectDisplayName11,
7672
+ selectIdentifier: selectIdentifier10,
7673
+ selectDisplayName: selectDisplayName10,
8026
7674
  verbose
8027
7675
  });
8028
7676
  }
@@ -8086,12 +7734,12 @@ var QuirkModule = {
8086
7734
  describe: "Commands for Context quirks",
8087
7735
  builder: (yargs36) => yargs36.command(QuirkPullModule).command(QuirkPushModule).command(QuirkGetModule).command(QuirkRemoveModule).command(QuirkListModule).command(QuirkUpdateModule).demandCommand(),
8088
7736
  handler: () => {
8089
- yargs22.help();
7737
+ yargs21.help();
8090
7738
  }
8091
7739
  };
8092
7740
 
8093
7741
  // src/commands/context/commands/signal.ts
8094
- import yargs23 from "yargs";
7742
+ import yargs22 from "yargs";
8095
7743
 
8096
7744
  // src/commands/context/commands/signal/get.ts
8097
7745
  import { UncachedSignalClient } from "@uniformdev/context/api";
@@ -8139,8 +7787,8 @@ var SignalListModule = {
8139
7787
  import { UncachedSignalClient as UncachedSignalClient3 } from "@uniformdev/context/api";
8140
7788
 
8141
7789
  // src/commands/context/commands/signal/_util.ts
8142
- var selectIdentifier12 = (source) => source.id;
8143
- var selectDisplayName12 = (source) => `${source.name} (pid: ${source.id})`;
7790
+ var selectIdentifier11 = (source) => source.id;
7791
+ var selectDisplayName11 = (source) => `${source.name} (pid: ${source.id})`;
8144
7792
 
8145
7793
  // src/commands/context/signalEngineDataSource.ts
8146
7794
  function createSignalEngineDataSource({
@@ -8150,8 +7798,8 @@ function createSignalEngineDataSource({
8150
7798
  const signals = (await client.get()).signals;
8151
7799
  for await (const def of signals) {
8152
7800
  const result = {
8153
- id: selectIdentifier12(def),
8154
- displayName: selectDisplayName12(def),
7801
+ id: selectIdentifier11(def),
7802
+ displayName: selectDisplayName11(def),
8155
7803
  providerId: def.id,
8156
7804
  object: def
8157
7805
  };
@@ -8225,8 +7873,8 @@ var SignalPullModule = {
8225
7873
  target = await createArraySyncEngineDataSource({
8226
7874
  name: `Package file ${directory}`,
8227
7875
  objects: packageContents.signals ?? [],
8228
- selectIdentifier: selectIdentifier12,
8229
- selectDisplayName: selectDisplayName12,
7876
+ selectIdentifier: selectIdentifier11,
7877
+ selectDisplayName: selectDisplayName11,
8230
7878
  onSyncComplete: async (_, synced) => {
8231
7879
  packageContents.signals = synced;
8232
7880
  writeContextPackage(directory, packageContents);
@@ -8235,8 +7883,8 @@ var SignalPullModule = {
8235
7883
  } else {
8236
7884
  target = await createFileSyncEngineDataSource({
8237
7885
  directory,
8238
- selectIdentifier: selectIdentifier12,
8239
- selectDisplayName: selectDisplayName12,
7886
+ selectIdentifier: selectIdentifier11,
7887
+ selectDisplayName: selectDisplayName11,
8240
7888
  format,
8241
7889
  verbose
8242
7890
  });
@@ -8298,14 +7946,14 @@ var SignalPushModule = {
8298
7946
  source = await createArraySyncEngineDataSource({
8299
7947
  name: `Package file ${directory}`,
8300
7948
  objects: packageContents.signals ?? [],
8301
- selectIdentifier: selectIdentifier12,
8302
- selectDisplayName: selectDisplayName12
7949
+ selectIdentifier: selectIdentifier11,
7950
+ selectDisplayName: selectDisplayName11
8303
7951
  });
8304
7952
  } else {
8305
7953
  source = await createFileSyncEngineDataSource({
8306
7954
  directory,
8307
- selectIdentifier: selectIdentifier12,
8308
- selectDisplayName: selectDisplayName12,
7955
+ selectIdentifier: selectIdentifier11,
7956
+ selectDisplayName: selectDisplayName11,
8309
7957
  verbose
8310
7958
  });
8311
7959
  }
@@ -8369,12 +8017,12 @@ var SignalModule = {
8369
8017
  describe: "Commands for Context signals",
8370
8018
  builder: (yargs36) => yargs36.command(SignalPullModule).command(SignalPushModule).command(SignalGetModule).command(SignalRemoveModule).command(SignalListModule).command(SignalUpdateModule).demandCommand(),
8371
8019
  handler: () => {
8372
- yargs23.help();
8020
+ yargs22.help();
8373
8021
  }
8374
8022
  };
8375
8023
 
8376
8024
  // src/commands/context/commands/test.ts
8377
- import yargs24 from "yargs";
8025
+ import yargs23 from "yargs";
8378
8026
 
8379
8027
  // src/commands/context/commands/test/get.ts
8380
8028
  import { UncachedTestClient } from "@uniformdev/context/api";
@@ -8422,8 +8070,8 @@ var TestListModule = {
8422
8070
  import { UncachedTestClient as UncachedTestClient3 } from "@uniformdev/context/api";
8423
8071
 
8424
8072
  // src/commands/context/commands/test/_util.ts
8425
- var selectIdentifier13 = (source) => source.id;
8426
- var selectDisplayName13 = (source) => `${source.name} (pid: ${source.id})`;
8073
+ var selectIdentifier12 = (source) => source.id;
8074
+ var selectDisplayName12 = (source) => `${source.name} (pid: ${source.id})`;
8427
8075
 
8428
8076
  // src/commands/context/testEngineDataSource.ts
8429
8077
  function createTestEngineDataSource({
@@ -8433,8 +8081,8 @@ function createTestEngineDataSource({
8433
8081
  const tests = (await client.get()).tests;
8434
8082
  for await (const def of tests) {
8435
8083
  const result = {
8436
- id: selectIdentifier13(def),
8437
- displayName: selectDisplayName13(def),
8084
+ id: selectIdentifier12(def),
8085
+ displayName: selectDisplayName12(def),
8438
8086
  providerId: def.id,
8439
8087
  object: def
8440
8088
  };
@@ -8508,8 +8156,8 @@ var TestPullModule = {
8508
8156
  target = await createArraySyncEngineDataSource({
8509
8157
  name: `Package file ${directory}`,
8510
8158
  objects: packageContents.tests ?? [],
8511
- selectIdentifier: selectIdentifier13,
8512
- selectDisplayName: selectDisplayName13,
8159
+ selectIdentifier: selectIdentifier12,
8160
+ selectDisplayName: selectDisplayName12,
8513
8161
  onSyncComplete: async (_, synced) => {
8514
8162
  packageContents.tests = synced;
8515
8163
  writeContextPackage(directory, packageContents);
@@ -8518,8 +8166,8 @@ var TestPullModule = {
8518
8166
  } else {
8519
8167
  target = await createFileSyncEngineDataSource({
8520
8168
  directory,
8521
- selectIdentifier: selectIdentifier13,
8522
- selectDisplayName: selectDisplayName13,
8169
+ selectIdentifier: selectIdentifier12,
8170
+ selectDisplayName: selectDisplayName12,
8523
8171
  format,
8524
8172
  verbose
8525
8173
  });
@@ -8581,14 +8229,14 @@ var TestPushModule = {
8581
8229
  source = await createArraySyncEngineDataSource({
8582
8230
  name: `Package file ${directory}`,
8583
8231
  objects: packageContents.tests ?? [],
8584
- selectIdentifier: selectIdentifier13,
8585
- selectDisplayName: selectDisplayName13
8232
+ selectIdentifier: selectIdentifier12,
8233
+ selectDisplayName: selectDisplayName12
8586
8234
  });
8587
8235
  } else {
8588
8236
  source = await createFileSyncEngineDataSource({
8589
8237
  directory,
8590
- selectIdentifier: selectIdentifier13,
8591
- selectDisplayName: selectDisplayName13,
8238
+ selectIdentifier: selectIdentifier12,
8239
+ selectDisplayName: selectDisplayName12,
8592
8240
  verbose
8593
8241
  });
8594
8242
  }
@@ -8649,7 +8297,7 @@ var TestModule = {
8649
8297
  describe: "Commands for Context A/B tests",
8650
8298
  builder: (yargs36) => yargs36.command(TestPullModule).command(TestPushModule).command(TestGetModule).command(TestRemoveModule).command(TestListModule).command(TestUpdateModule).demandCommand(),
8651
8299
  handler: () => {
8652
- yargs24.help();
8300
+ yargs23.help();
8653
8301
  }
8654
8302
  };
8655
8303
 
@@ -8660,27 +8308,27 @@ var ContextCommand = {
8660
8308
  describe: "Uniform Context commands",
8661
8309
  builder: (yargs36) => yargs36.command(ManifestModule).command(SignalModule).command(EnrichmentModule).command(AggregateModule).command(QuirkModule).command(TestModule).demandCommand(),
8662
8310
  handler: () => {
8663
- yargs25.showHelp();
8311
+ yargs24.showHelp();
8664
8312
  }
8665
8313
  };
8666
8314
 
8667
8315
  // src/commands/integration/index.ts
8668
- import yargs28 from "yargs";
8316
+ import yargs27 from "yargs";
8669
8317
 
8670
8318
  // src/commands/integration/commands/definition.ts
8671
- import yargs27 from "yargs";
8319
+ import yargs26 from "yargs";
8672
8320
 
8673
8321
  // src/commands/integration/commands/definition/edgehancer/edgehancer.ts
8674
- import yargs26 from "yargs";
8322
+ import yargs25 from "yargs";
8675
8323
 
8676
8324
  // src/commands/integration/commands/definition/edgehancer/deploy.ts
8677
8325
  import { readFileSync } from "fs";
8678
8326
 
8679
8327
  // src/commands/integration/commands/definition/edgehancer/EdgehancerClient.ts
8680
8328
  import { createLimitPolicy as createLimitPolicy2 } from "@uniformdev/canvas";
8681
- import { ApiClient as ApiClient2 } from "@uniformdev/context/api";
8329
+ import { ApiClient } from "@uniformdev/context/api";
8682
8330
  var ENDPOINT = "/api/v1/integration-edgehancers";
8683
- var EdgehancerClient = class extends ApiClient2 {
8331
+ var EdgehancerClient = class extends ApiClient {
8684
8332
  constructor(options) {
8685
8333
  if (!options.limitPolicy) {
8686
8334
  options.limitPolicy = createLimitPolicy2({});
@@ -8781,15 +8429,15 @@ var IntegrationEdgehancerModule = {
8781
8429
  describe: "Commands for managing custom integration edgehancers at the team level.",
8782
8430
  builder: (yargs36) => yargs36.command(IntegrationEdgehancerDeployModule).command(IntegrationEdgehancerRemoveModule).demandCommand(),
8783
8431
  handler: () => {
8784
- yargs26.help();
8432
+ yargs25.help();
8785
8433
  }
8786
8434
  };
8787
8435
 
8788
8436
  // src/commands/integration/commands/definition/DefinitionClient.ts
8789
8437
  import { createLimitPolicy as createLimitPolicy3 } from "@uniformdev/canvas";
8790
- import { ApiClient as ApiClient3 } from "@uniformdev/context/api";
8438
+ import { ApiClient as ApiClient2 } from "@uniformdev/context/api";
8791
8439
  var ENDPOINT2 = "/api/v1/integration-definitions";
8792
- var DefinitionClient = class extends ApiClient3 {
8440
+ var DefinitionClient = class extends ApiClient2 {
8793
8441
  constructor(options) {
8794
8442
  if (!options.limitPolicy) {
8795
8443
  options.limitPolicy = createLimitPolicy3({});
@@ -8866,15 +8514,15 @@ var IntegrationDefinitionModule = {
8866
8514
  describe: "Commands for managing custom integration definitions at the team level.",
8867
8515
  builder: (yargs36) => yargs36.command(IntegrationDefinitionRemoveModule).command(IntegrationDefinitionRegisterModule).command(IntegrationEdgehancerModule).demandCommand(),
8868
8516
  handler: () => {
8869
- yargs27.help();
8517
+ yargs26.help();
8870
8518
  }
8871
8519
  };
8872
8520
 
8873
8521
  // src/commands/integration/commands/InstallClient.ts
8874
8522
  import { createLimitPolicy as createLimitPolicy4 } from "@uniformdev/canvas";
8875
- import { ApiClient as ApiClient4 } from "@uniformdev/context/api";
8523
+ import { ApiClient as ApiClient3 } from "@uniformdev/context/api";
8876
8524
  var ENDPOINT3 = "/api/v1/integration-installations";
8877
- var InstallClient = class extends ApiClient4 {
8525
+ var InstallClient = class extends ApiClient3 {
8878
8526
  constructor(options) {
8879
8527
  if (!options.limitPolicy) {
8880
8528
  options.limitPolicy = createLimitPolicy4({});
@@ -8954,7 +8602,7 @@ var IntegrationCommand = {
8954
8602
  describe: "Integration management commands",
8955
8603
  builder: (yargs36) => yargs36.command(IntegrationDefinitionModule).command(IntegrationInstallModule).command(IntegrationUninstallModule).demandCommand(),
8956
8604
  handler: () => {
8957
- yargs28.showHelp();
8605
+ yargs27.showHelp();
8958
8606
  }
8959
8607
  };
8960
8608
 
@@ -9160,7 +8808,7 @@ async function getBearerToken(baseUrl) {
9160
8808
  }
9161
8809
 
9162
8810
  // src/client.ts
9163
- import { z as z2 } from "zod";
8811
+ import { z } from "zod";
9164
8812
 
9165
8813
  // src/auth/api-key.ts
9166
8814
  var READ_PERMISSIONS = ["PROJECT", "UPM_PUB", "OPT_PUB", "OPT_READ", "UPM_READ"];
@@ -9215,12 +8863,12 @@ var makeReadApiKey = (teamId, projectId) => makeApiKey(teamId, projectId, "Creat
9215
8863
  var makeWriteApiKey = (teamId, projectId) => makeApiKey(teamId, projectId, "Created by Uniform New (write)", WRITE_PERMISSIONS);
9216
8864
 
9217
8865
  // src/client.ts
9218
- var createTeamOrProjectSchema = z2.object({ id: z2.string().min(1) });
9219
- var createApiKeySchema = z2.object({ apiKey: z2.string().min(1) });
9220
- var getLimitsSchema = z2.object({
9221
- limits: z2.object({
9222
- projects: z2.array(
9223
- z2.object({ id: z2.string().min(1), name: z2.string().min(1), used: z2.number(), limit: z2.number() })
8866
+ var createTeamOrProjectSchema = z.object({ id: z.string().min(1) });
8867
+ var createApiKeySchema = z.object({ apiKey: z.string().min(1) });
8868
+ var getLimitsSchema = z.object({
8869
+ limits: z.object({
8870
+ projects: z.array(
8871
+ z.object({ id: z.string().min(1), name: z.string().min(1), used: z.number(), limit: z.number() })
9224
8872
  )
9225
8873
  })
9226
8874
  });
@@ -9330,7 +8978,7 @@ var createClient = (baseUrl, authToken) => {
9330
8978
  method: "PUT",
9331
8979
  body: JSON.stringify({ teamId, data: manifest })
9332
8980
  },
9333
- z2.object({ type: z2.string() })
8981
+ z.object({ type: z.string() })
9334
8982
  );
9335
8983
  return type;
9336
8984
  } catch (err) {
@@ -9582,7 +9230,7 @@ async function chooseTeam(user, prompt, telemetry) {
9582
9230
 
9583
9231
  // src/auth/user-info.ts
9584
9232
  import { gql, request } from "graphql-request";
9585
- import { z as z3 } from "zod";
9233
+ import { z as z2 } from "zod";
9586
9234
  var query = gql`
9587
9235
  query GetUserInfo($subject: String!) {
9588
9236
  info: identities_by_pk(subject: $subject) {
@@ -9601,19 +9249,19 @@ var query = gql`
9601
9249
  }
9602
9250
  }
9603
9251
  `;
9604
- var schema = z3.object({
9605
- info: z3.object({
9606
- name: z3.string().min(1),
9607
- email_address: z3.string().min(1).nullable(),
9608
- teams: z3.array(
9609
- z3.object({
9610
- team: z3.object({
9611
- name: z3.string().min(1),
9612
- id: z3.string().min(1),
9613
- sites: z3.array(
9614
- z3.object({
9615
- name: z3.string().min(1),
9616
- id: z3.string().min(1)
9252
+ var schema = z2.object({
9253
+ info: z2.object({
9254
+ name: z2.string().min(1),
9255
+ email_address: z2.string().min(1).nullable(),
9256
+ teams: z2.array(
9257
+ z2.object({
9258
+ team: z2.object({
9259
+ name: z2.string().min(1),
9260
+ id: z2.string().min(1),
9261
+ sites: z2.array(
9262
+ z2.object({
9263
+ name: z2.string().min(1),
9264
+ id: z2.string().min(1)
9617
9265
  })
9618
9266
  )
9619
9267
  })
@@ -10015,15 +9663,15 @@ var NewMeshCmd = {
10015
9663
  };
10016
9664
 
10017
9665
  // src/commands/project-map/index.ts
10018
- import yargs31 from "yargs";
9666
+ import yargs30 from "yargs";
10019
9667
 
10020
9668
  // src/commands/project-map/commands/projectMapDefinition.ts
10021
- import yargs29 from "yargs";
9669
+ import yargs28 from "yargs";
10022
9670
 
10023
9671
  // src/commands/project-map/commands/ProjectMapDefinition/_util.ts
10024
9672
  import { UncachedProjectMapClient } from "@uniformdev/project-map";
10025
- var selectIdentifier14 = (source) => source.id;
10026
- var selectDisplayName14 = (source) => `${source.name} (pid: ${source.id})`;
9673
+ var selectIdentifier13 = (source) => source.id;
9674
+ var selectDisplayName13 = (source) => `${source.name} (pid: ${source.id})`;
10027
9675
  function getProjectMapClient(options) {
10028
9676
  return new UncachedProjectMapClient({ ...options, limitPolicy: cliLimitPolicy });
10029
9677
  }
@@ -10087,9 +9735,9 @@ function createProjectMapDefinitionEngineDataSource({
10087
9735
  const projectMaps = (await client.getProjectMapDefinitions()).projectMaps;
10088
9736
  for await (const def of projectMaps) {
10089
9737
  const result = {
10090
- id: selectIdentifier14(def),
10091
- displayName: selectDisplayName14(def),
10092
- providerId: selectIdentifier14(def),
9738
+ id: selectIdentifier13(def),
9739
+ displayName: selectDisplayName13(def),
9740
+ providerId: selectIdentifier13(def),
10093
9741
  object: def
10094
9742
  };
10095
9743
  yield result;
@@ -10162,8 +9810,8 @@ var ProjectMapDefinitionPullModule = {
10162
9810
  target = await createArraySyncEngineDataSource({
10163
9811
  name: `Package file ${directory}`,
10164
9812
  objects: packageContents.projectMaps ?? [],
10165
- selectIdentifier: selectIdentifier14,
10166
- selectDisplayName: selectDisplayName14,
9813
+ selectIdentifier: selectIdentifier13,
9814
+ selectDisplayName: selectDisplayName13,
10167
9815
  onSyncComplete: async (_, synced) => {
10168
9816
  packageContents.projectMaps = synced;
10169
9817
  writeContextPackage2(directory, packageContents);
@@ -10172,8 +9820,8 @@ var ProjectMapDefinitionPullModule = {
10172
9820
  } else {
10173
9821
  target = await createFileSyncEngineDataSource({
10174
9822
  directory,
10175
- selectIdentifier: selectIdentifier14,
10176
- selectDisplayName: selectDisplayName14,
9823
+ selectIdentifier: selectIdentifier13,
9824
+ selectDisplayName: selectDisplayName13,
10177
9825
  format,
10178
9826
  verbose
10179
9827
  });
@@ -10234,14 +9882,14 @@ var ProjectMapDefinitionPushModule = {
10234
9882
  source = await createArraySyncEngineDataSource({
10235
9883
  name: `Package file ${directory}`,
10236
9884
  objects: packageContents.projectMaps ?? [],
10237
- selectIdentifier: selectIdentifier14,
10238
- selectDisplayName: selectDisplayName14
9885
+ selectIdentifier: selectIdentifier13,
9886
+ selectDisplayName: selectDisplayName13
10239
9887
  });
10240
9888
  } else {
10241
9889
  source = await createFileSyncEngineDataSource({
10242
9890
  directory,
10243
- selectIdentifier: selectIdentifier14,
10244
- selectDisplayName: selectDisplayName14,
9891
+ selectIdentifier: selectIdentifier13,
9892
+ selectDisplayName: selectDisplayName13,
10245
9893
  verbose
10246
9894
  });
10247
9895
  }
@@ -10300,12 +9948,12 @@ var ProjectMapDefinitionModule = {
10300
9948
  describe: "Commands for ProjectMap Definitions",
10301
9949
  builder: (yargs36) => yargs36.command(ProjectMapDefinitionPullModule).command(ProjectMapDefinitionPushModule).command(ProjectMapDefinitionGetModule).command(ProjectMapDefinitionRemoveModule).command(ProjectMapDefinitionListModule).command(ProjectMapDefinitionUpdateModule).demandCommand(),
10302
9950
  handler: () => {
10303
- yargs29.help();
9951
+ yargs28.help();
10304
9952
  }
10305
9953
  };
10306
9954
 
10307
9955
  // src/commands/project-map/commands/projectMapNode.ts
10308
- import yargs30 from "yargs";
9956
+ import yargs29 from "yargs";
10309
9957
 
10310
9958
  // src/commands/project-map/commands/ProjectMapNode/get.ts
10311
9959
  var ProjectMapNodeGetModule = {
@@ -10362,12 +10010,12 @@ var ProjectMapNodeListModule = {
10362
10010
  };
10363
10011
 
10364
10012
  // src/commands/project-map/commands/ProjectMapNode/_util.ts
10365
- var selectIdentifier15 = (source, projectId) => [
10013
+ var selectIdentifier14 = (source, projectId) => [
10366
10014
  projectId + source.projectMapId + source.id,
10367
10015
  projectId + source.projectMapId + source.path
10368
10016
  ];
10369
10017
  var selectFilename = (source) => cleanFileName(`${source.pathSegment}_${source.id}`);
10370
- var selectDisplayName15 = (source) => `${source.name} (pid: ${source.id})`;
10018
+ var selectDisplayName14 = (source) => `${source.name} (pid: ${source.id})`;
10371
10019
 
10372
10020
  // src/commands/project-map/ProjectMapNodeEngineDataSource.ts
10373
10021
  function createProjectMapNodeEngineDataSource({
@@ -10381,9 +10029,9 @@ function createProjectMapNodeEngineDataSource({
10381
10029
  for await (const node of nodes ?? []) {
10382
10030
  if (node) {
10383
10031
  const result = {
10384
- id: selectIdentifier15({ ...node, projectMapId: projectMap.id }, projectId),
10385
- displayName: selectDisplayName15(node),
10386
- providerId: selectIdentifier15({ ...node, projectMapId: projectMap.id }, projectId)[0],
10032
+ id: selectIdentifier14({ ...node, projectMapId: projectMap.id }, projectId),
10033
+ displayName: selectDisplayName14(node),
10034
+ providerId: selectIdentifier14({ ...node, projectMapId: projectMap.id }, projectId)[0],
10387
10035
  object: { ...node, projectMapId: projectMap.id }
10388
10036
  };
10389
10037
  yield result;
@@ -10467,7 +10115,7 @@ var ProjectMapNodePullModule = {
10467
10115
  let target;
10468
10116
  const isPackage = isPathAPackageFile(directory);
10469
10117
  const expandedSelectIdentifier = (object) => {
10470
- return selectIdentifier15(object, projectId);
10118
+ return selectIdentifier14(object, projectId);
10471
10119
  };
10472
10120
  if (isPackage) {
10473
10121
  const packageContents = readContextPackage2(directory, false, verbose);
@@ -10475,7 +10123,7 @@ var ProjectMapNodePullModule = {
10475
10123
  name: `Package file ${directory}`,
10476
10124
  objects: packageContents.projectMapNodes ?? [],
10477
10125
  selectIdentifier: expandedSelectIdentifier,
10478
- selectDisplayName: selectDisplayName15,
10126
+ selectDisplayName: selectDisplayName14,
10479
10127
  onSyncComplete: async (_, synced) => {
10480
10128
  packageContents.projectMapNodes = synced;
10481
10129
  writeContextPackage2(directory, packageContents);
@@ -10485,7 +10133,7 @@ var ProjectMapNodePullModule = {
10485
10133
  target = await createFileSyncEngineDataSource({
10486
10134
  directory,
10487
10135
  selectIdentifier: expandedSelectIdentifier,
10488
- selectDisplayName: selectDisplayName15,
10136
+ selectDisplayName: selectDisplayName14,
10489
10137
  format,
10490
10138
  selectFilename,
10491
10139
  verbose
@@ -10551,7 +10199,7 @@ var ProjectMapNodePushModule = {
10551
10199
  let source;
10552
10200
  const isPackage = isPathAPackageFile(directory);
10553
10201
  const expandedSelectIdentifier = (object) => {
10554
- return selectIdentifier15(object, projectId);
10202
+ return selectIdentifier14(object, projectId);
10555
10203
  };
10556
10204
  if (isPackage) {
10557
10205
  const packageContents = readContextPackage2(directory, true, verbose);
@@ -10561,13 +10209,13 @@ var ProjectMapNodePushModule = {
10561
10209
  return a.path.length - b.path.length;
10562
10210
  }) ?? [],
10563
10211
  selectIdentifier: expandedSelectIdentifier,
10564
- selectDisplayName: selectDisplayName15
10212
+ selectDisplayName: selectDisplayName14
10565
10213
  });
10566
10214
  } else {
10567
10215
  source = await createFileSyncEngineDataSource({
10568
10216
  directory,
10569
10217
  selectIdentifier: expandedSelectIdentifier,
10570
- selectDisplayName: selectDisplayName15,
10218
+ selectDisplayName: selectDisplayName14,
10571
10219
  selectFilename,
10572
10220
  verbose
10573
10221
  });
@@ -10599,7 +10247,7 @@ var ProjectMapNodePushModule = {
10599
10247
  name: `Nodes re-push from ${directory}`,
10600
10248
  objects: Array.from(nodesFailedDueToMissingParent),
10601
10249
  selectIdentifier: expandedSelectIdentifier,
10602
- selectDisplayName: selectDisplayName15
10250
+ selectDisplayName: selectDisplayName14
10603
10251
  });
10604
10252
  await attemptSync();
10605
10253
  } else {
@@ -10656,7 +10304,7 @@ var ProjectMapNodeModule = {
10656
10304
  describe: "Commands for ProjectMap Nodes",
10657
10305
  builder: (yargs36) => yargs36.command(ProjectMapNodePullModule).command(ProjectMapNodePushModule).command(ProjectMapNodeGetModule).command(ProjectMapNodeRemoveModule).command(ProjectMapNodeListModule).command(ProjectMapNodeUpdateModule).demandCommand(),
10658
10306
  handler: () => {
10659
- yargs30.help();
10307
+ yargs29.help();
10660
10308
  }
10661
10309
  };
10662
10310
 
@@ -10667,24 +10315,24 @@ var ProjectMapCommand = {
10667
10315
  describe: "Uniform ProjectMap commands",
10668
10316
  builder: (yargs36) => yargs36.command(ProjectMapNodeModule).command(ProjectMapDefinitionModule).demandCommand(),
10669
10317
  handler: () => {
10670
- yargs31.showHelp();
10318
+ yargs30.showHelp();
10671
10319
  }
10672
10320
  };
10673
10321
 
10674
10322
  // src/commands/redirect/index.ts
10675
- import yargs33 from "yargs";
10323
+ import yargs32 from "yargs";
10676
10324
 
10677
10325
  // src/commands/redirect/commands/redirect.ts
10678
- import yargs32 from "yargs";
10326
+ import yargs31 from "yargs";
10679
10327
 
10680
10328
  // src/commands/redirect/commands/RedirectDefinition/_util.ts
10681
10329
  import { UncachedRedirectClient } from "@uniformdev/redirect";
10682
- var selectIdentifier16 = (source) => source.id;
10330
+ var selectIdentifier15 = (source) => source.id;
10683
10331
  var selectFilename2 = (source) => {
10684
10332
  const index = source.sourceUrl.lastIndexOf("/");
10685
10333
  return cleanFileName(source.sourceUrl.substring(index + 1)) + `_${source.id}`;
10686
10334
  };
10687
- var selectDisplayName16 = (source) => {
10335
+ var selectDisplayName15 = (source) => {
10688
10336
  let pathName = source.sourceUrl;
10689
10337
  if (pathName.length > 30) {
10690
10338
  const slashIndex = source.sourceUrl.indexOf("/", source.sourceUrl.length - 30);
@@ -10755,9 +10403,9 @@ function createRedirectDefinitionEngineDataSource({
10755
10403
  const redirects = client.getAllRedirects();
10756
10404
  for await (const redirect of redirects) {
10757
10405
  const result = {
10758
- id: selectIdentifier16(redirect.redirect),
10759
- displayName: selectDisplayName16(redirect.redirect),
10760
- providerId: selectIdentifier16(redirect.redirect),
10406
+ id: selectIdentifier15(redirect.redirect),
10407
+ displayName: selectDisplayName15(redirect.redirect),
10408
+ providerId: selectIdentifier15(redirect.redirect),
10761
10409
  object: redirect.redirect
10762
10410
  };
10763
10411
  yield result;
@@ -10828,8 +10476,8 @@ var RedirectDefinitionPullModule = {
10828
10476
  target = await createArraySyncEngineDataSource({
10829
10477
  name: `Package file ${directory}`,
10830
10478
  objects: packageContents.redirects ?? [],
10831
- selectIdentifier: selectIdentifier16,
10832
- selectDisplayName: selectDisplayName16,
10479
+ selectIdentifier: selectIdentifier15,
10480
+ selectDisplayName: selectDisplayName15,
10833
10481
  onSyncComplete: async (_, synced) => {
10834
10482
  packageContents.redirects = synced;
10835
10483
  writeContextPackage3(directory, packageContents);
@@ -10839,8 +10487,8 @@ var RedirectDefinitionPullModule = {
10839
10487
  target = await createFileSyncEngineDataSource({
10840
10488
  directory,
10841
10489
  selectFilename: selectFilename2,
10842
- selectIdentifier: selectIdentifier16,
10843
- selectDisplayName: selectDisplayName16,
10490
+ selectIdentifier: selectIdentifier15,
10491
+ selectDisplayName: selectDisplayName15,
10844
10492
  format,
10845
10493
  verbose
10846
10494
  });
@@ -10901,14 +10549,14 @@ var RedirectDefinitionPushModule = {
10901
10549
  source = await createArraySyncEngineDataSource({
10902
10550
  name: `Package file ${directory}`,
10903
10551
  objects: packageContents.redirects ?? [],
10904
- selectIdentifier: selectIdentifier16,
10905
- selectDisplayName: selectDisplayName16
10552
+ selectIdentifier: selectIdentifier15,
10553
+ selectDisplayName: selectDisplayName15
10906
10554
  });
10907
10555
  } else {
10908
10556
  source = await createFileSyncEngineDataSource({
10909
10557
  directory,
10910
- selectIdentifier: selectIdentifier16,
10911
- selectDisplayName: selectDisplayName16,
10558
+ selectIdentifier: selectIdentifier15,
10559
+ selectDisplayName: selectDisplayName15,
10912
10560
  verbose
10913
10561
  });
10914
10562
  }
@@ -10967,7 +10615,7 @@ var RedirectDefinitionModule = {
10967
10615
  describe: "Commands for Redirect Definitions",
10968
10616
  builder: (yargs36) => yargs36.command(RedirectDefinitionPullModule).command(RedirectDefinitionPushModule).command(RedirectDefinitionGetModule).command(RedirectDefinitionRemoveModule).command(RedirectDefinitionListModule).command(RedirectDefinitionUpdateModule).demandCommand(),
10969
10617
  handler: () => {
10970
- yargs32.help();
10618
+ yargs31.help();
10971
10619
  }
10972
10620
  };
10973
10621
 
@@ -10978,12 +10626,281 @@ var RedirectCommand = {
10978
10626
  describe: "Uniform Redirect commands",
10979
10627
  builder: (yargs36) => yargs36.command(RedirectDefinitionModule).demandCommand(),
10980
10628
  handler: () => {
10981
- yargs33.showHelp();
10629
+ yargs32.showHelp();
10982
10630
  }
10983
10631
  };
10984
10632
 
10985
10633
  // src/commands/sync/index.ts
10986
- import yargs34 from "yargs";
10634
+ import yargs33 from "yargs";
10635
+
10636
+ // src/webhooksClient.ts
10637
+ import { ApiClient as ApiClient4 } from "@uniformdev/context/api";
10638
+ import PQueue3 from "p-queue";
10639
+ import { Svix } from "svix";
10640
+ import { z as z3 } from "zod";
10641
+ var WEBHOOKS_DASHBOARD_BASE_PATH = "/api/v1/svix-dashboard";
10642
+ var WebhooksClient = class extends ApiClient4 {
10643
+ constructor(options) {
10644
+ super(options);
10645
+ }
10646
+ async getToken() {
10647
+ const { projectId } = this.options;
10648
+ const { dashboard_url: dashboardUrl } = await this.apiClient(
10649
+ this.createUrl(WEBHOOKS_DASHBOARD_BASE_PATH, {
10650
+ projectId
10651
+ })
10652
+ );
10653
+ if (!dashboardUrl) {
10654
+ throw new Error("Webhooks are not activated for this project");
10655
+ }
10656
+ const key = dashboardUrl.split("key=")[1];
10657
+ if (!key) {
10658
+ throw new Error("Failed to get webhooks token");
10659
+ }
10660
+ const keySchema = z3.object({
10661
+ appId: z3.string(),
10662
+ oneTimeToken: z3.string(),
10663
+ region: z3.enum(["us", "eu"])
10664
+ });
10665
+ const { appId, oneTimeToken, region } = keySchema.parse(JSON.parse(atob(key)));
10666
+ const tokenSchema = z3.object({
10667
+ token: z3.string()
10668
+ });
10669
+ const tokenResponse = await fetch(`https://api.${region}.svix.com/api/v1/auth/one-time-token`, {
10670
+ method: "POST",
10671
+ body: JSON.stringify({
10672
+ oneTimeToken
10673
+ }),
10674
+ headers: {
10675
+ "content-type": "application/json"
10676
+ }
10677
+ });
10678
+ const tokenData = await tokenResponse.json();
10679
+ const { token: svixToken } = tokenSchema.parse(tokenData);
10680
+ return {
10681
+ appId,
10682
+ token: svixToken
10683
+ };
10684
+ }
10685
+ async get() {
10686
+ const webhooksAPIQueue = new PQueue3({ concurrency: 10 });
10687
+ const { appId, token } = await this.getToken();
10688
+ const svix = new Svix(token);
10689
+ const getEndpoints = async ({
10690
+ iterator,
10691
+ endpoints: endpoints2 = []
10692
+ } = {
10693
+ endpoints: []
10694
+ }) => {
10695
+ const {
10696
+ data,
10697
+ done,
10698
+ iterator: nextIterator
10699
+ } = await webhooksAPIQueue.add(
10700
+ async () => svix.endpoint.list(appId, {
10701
+ limit: 100,
10702
+ iterator
10703
+ }),
10704
+ {
10705
+ throwOnTimeout: true
10706
+ }
10707
+ );
10708
+ if (!done && nextIterator) {
10709
+ return getEndpoints({
10710
+ iterator: nextIterator,
10711
+ endpoints: [...endpoints2, ...data]
10712
+ });
10713
+ }
10714
+ return [...endpoints2, ...data];
10715
+ };
10716
+ const endpoints = await getEndpoints();
10717
+ return Promise.all(
10718
+ endpoints.map(async (endpoint) => {
10719
+ const headers = await webhooksAPIQueue.add(async () => svix.endpoint.getHeaders(appId, endpoint.id), {
10720
+ throwOnTimeout: true
10721
+ }).catch(() => null);
10722
+ const transformation = await webhooksAPIQueue.add(async () => svix.endpoint.transformationGet(appId, endpoint.id), {
10723
+ throwOnTimeout: true
10724
+ }).catch(() => null);
10725
+ return {
10726
+ endpoint,
10727
+ headers,
10728
+ transformation
10729
+ };
10730
+ })
10731
+ );
10732
+ }
10733
+ async put(webhook) {
10734
+ const { appId, token } = await this.getToken();
10735
+ const svix = new Svix(token);
10736
+ let existingEndpoint = null;
10737
+ try {
10738
+ existingEndpoint = await svix.endpoint.get(appId, webhook.endpoint.id);
10739
+ } catch {
10740
+ }
10741
+ if (existingEndpoint) {
10742
+ existingEndpoint = await svix.endpoint.patch(appId, webhook.endpoint.id, {
10743
+ ...webhook.endpoint,
10744
+ uid: existingEndpoint.uid
10745
+ });
10746
+ } else {
10747
+ existingEndpoint = await svix.endpoint.create(appId, {
10748
+ ...webhook.endpoint,
10749
+ uid: webhook.endpoint.id
10750
+ });
10751
+ }
10752
+ if (webhook.headers) {
10753
+ await svix.endpoint.updateHeaders(appId, existingEndpoint.id, webhook.headers);
10754
+ }
10755
+ if (webhook.transformation) {
10756
+ await svix.endpoint.transformationPartialUpdate(appId, existingEndpoint.id, webhook.transformation);
10757
+ }
10758
+ return existingEndpoint;
10759
+ }
10760
+ async delete(endpointId) {
10761
+ const { appId, token } = await this.getToken();
10762
+ const svix = new Svix(token);
10763
+ await svix.endpoint.delete(appId, endpointId);
10764
+ }
10765
+ };
10766
+
10767
+ // src/commands/webhook/commands/_util.ts
10768
+ var selectIdentifier16 = (webhook) => webhook.endpoint.uid ?? webhook.endpoint.id;
10769
+ var selectDisplayName16 = (webhook) => `${webhook.endpoint.url} (pid: ${webhook.endpoint.uid ?? webhook.endpoint.id})`;
10770
+ var getWebhooksClient = (options) => new WebhooksClient({ ...options, bypassCache: true, limitPolicy: cliLimitPolicy });
10771
+ var compareWebhooks = (source, target) => {
10772
+ const { endpoint: sourceEndpoint, ...sourceWithoutEndpoint } = source.object;
10773
+ const { endpoint: targetEndpoint, ...targetWithoutEndpoint } = target.object;
10774
+ const {
10775
+ id: sourceId,
10776
+ uid: sourceUid,
10777
+ version: sourceVersion,
10778
+ createdAt: sourceCreatedAt,
10779
+ updatedAt: sourceUpdatedAt,
10780
+ ...sourceToCompare
10781
+ } = sourceEndpoint;
10782
+ const {
10783
+ id: targetId,
10784
+ uid: targetUid,
10785
+ version: targetVersion,
10786
+ createdAt: targetCreatedAt,
10787
+ updatedAt: targetUpdatedAt,
10788
+ ...targetToCompare
10789
+ } = targetEndpoint;
10790
+ return serializedDequal(
10791
+ { ...sourceWithoutEndpoint, endpoint: sourceToCompare },
10792
+ { ...targetWithoutEndpoint, endpoint: targetToCompare }
10793
+ );
10794
+ };
10795
+
10796
+ // src/commands/webhook/webhookEngineDataSource.ts
10797
+ function createWebhookEngineDataSource({
10798
+ client
10799
+ }) {
10800
+ async function* getObjects() {
10801
+ const webhooks = await client.get();
10802
+ for await (const webhook of webhooks) {
10803
+ const result = {
10804
+ id: selectIdentifier16(webhook),
10805
+ displayName: selectDisplayName16(webhook),
10806
+ providerId: webhook.endpoint.id,
10807
+ object: webhook
10808
+ };
10809
+ yield result;
10810
+ }
10811
+ }
10812
+ return {
10813
+ name: "Uniform API",
10814
+ objects: getObjects(),
10815
+ deleteObject: async (providerId) => {
10816
+ await client.delete(providerId);
10817
+ },
10818
+ writeObject: async (object) => {
10819
+ await client.put(object.object);
10820
+ }
10821
+ };
10822
+ }
10823
+
10824
+ // src/commands/webhook/commands/pull.ts
10825
+ var WebhookPullModule = {
10826
+ command: "pull <directory>",
10827
+ describe: "Pulls all webhooks to local files in a directory",
10828
+ builder: (yargs36) => withConfiguration(
10829
+ withApiOptions(
10830
+ withDebugOptions(
10831
+ withProjectOptions(
10832
+ withDiffOptions(
10833
+ yargs36.positional("directory", {
10834
+ describe: "Directory to save to. If a filename ending in yaml or json is used, a package file will be created instead of files in the directory.",
10835
+ type: "string"
10836
+ }).option("format", {
10837
+ alias: ["f"],
10838
+ describe: "Output format",
10839
+ default: "yaml",
10840
+ choices: ["yaml", "json"],
10841
+ type: "string"
10842
+ }).option("mode", {
10843
+ alias: ["m"],
10844
+ describe: 'What kind of changes can be made. "create" = create new files, update nothing. "createOrUpdate" = create new files, update existing, delete nothing. "mirror" = create, update, and delete to mirror state',
10845
+ choices: ["create", "createOrUpdate", "mirror"],
10846
+ default: "mirror",
10847
+ type: "string"
10848
+ })
10849
+ )
10850
+ )
10851
+ )
10852
+ )
10853
+ ),
10854
+ handler: async ({
10855
+ apiHost,
10856
+ apiKey,
10857
+ proxy,
10858
+ directory,
10859
+ format,
10860
+ mode,
10861
+ whatIf,
10862
+ project: projectId,
10863
+ diff: diffMode,
10864
+ allowEmptySource,
10865
+ verbose
10866
+ }) => {
10867
+ const fetch2 = nodeFetchProxy(proxy, verbose);
10868
+ const client = getWebhooksClient({ apiKey, apiHost, fetch: fetch2, projectId });
10869
+ const source = createWebhookEngineDataSource({ client });
10870
+ let target;
10871
+ const isPackage = isPathAPackageFile(directory);
10872
+ if (isPackage) {
10873
+ const packageContents = readCanvasPackage(directory, false, verbose);
10874
+ target = await createArraySyncEngineDataSource({
10875
+ name: `Package file ${directory}`,
10876
+ objects: packageContents.webhooks ?? [],
10877
+ selectIdentifier: selectIdentifier16,
10878
+ selectDisplayName: selectDisplayName16,
10879
+ onSyncComplete: async (_, synced) => {
10880
+ packageContents.webhooks = synced;
10881
+ writeCanvasPackage(directory, packageContents);
10882
+ }
10883
+ });
10884
+ } else {
10885
+ target = await createFileSyncEngineDataSource({
10886
+ directory,
10887
+ selectIdentifier: selectIdentifier16,
10888
+ selectDisplayName: selectDisplayName16,
10889
+ format,
10890
+ verbose
10891
+ });
10892
+ }
10893
+ await syncEngine({
10894
+ source,
10895
+ target,
10896
+ mode,
10897
+ whatIf,
10898
+ allowEmptySource: allowEmptySource ?? true,
10899
+ log: createSyncEngineConsoleLogger({ diffMode }),
10900
+ compareContents: compareWebhooks
10901
+ });
10902
+ }
10903
+ };
10987
10904
 
10988
10905
  // src/commands/sync/commands/util.ts
10989
10906
  import ora2 from "ora";
@@ -11193,6 +11110,75 @@ var getFormat = (entityType, config2) => {
11193
11110
  });
11194
11111
  };
11195
11112
 
11113
+ // src/commands/webhook/commands/push.ts
11114
+ var WebhookPushModule = {
11115
+ command: "push <directory>",
11116
+ describe: "Pushes all webhooks from files in a directory to Uniform",
11117
+ builder: (yargs36) => withConfiguration(
11118
+ withDebugOptions(
11119
+ withApiOptions(
11120
+ withProjectOptions(
11121
+ withDiffOptions(
11122
+ yargs36.positional("directory", {
11123
+ describe: "Directory to read from. If a filename is used, a package will be read instead.",
11124
+ type: "string"
11125
+ }).option("mode", {
11126
+ alias: ["m"],
11127
+ describe: 'What kind of changes can be made. "create" = create new, update nothing. "createOrUpdate" = create new, update existing, delete nothing. "mirror" = create, update, and delete',
11128
+ choices: ["create", "createOrUpdate", "mirror"],
11129
+ default: "mirror",
11130
+ type: "string"
11131
+ })
11132
+ )
11133
+ )
11134
+ )
11135
+ )
11136
+ ),
11137
+ handler: async ({
11138
+ apiHost,
11139
+ apiKey,
11140
+ proxy,
11141
+ directory,
11142
+ mode,
11143
+ whatIf,
11144
+ project: projectId,
11145
+ diff: diffMode,
11146
+ allowEmptySource,
11147
+ verbose
11148
+ }) => {
11149
+ const fetch2 = nodeFetchProxy(proxy, verbose);
11150
+ const client = getWebhooksClient({ apiKey, apiHost, fetch: fetch2, projectId });
11151
+ let source;
11152
+ const isPackage = isPathAPackageFile(directory);
11153
+ if (isPackage) {
11154
+ const packageContents = readCanvasPackage(directory, true, verbose);
11155
+ source = await createArraySyncEngineDataSource({
11156
+ name: `Package file ${directory}`,
11157
+ objects: packageContents.webhooks ?? [],
11158
+ selectIdentifier: selectIdentifier16,
11159
+ selectDisplayName: selectDisplayName16
11160
+ });
11161
+ } else {
11162
+ source = await createFileSyncEngineDataSource({
11163
+ directory,
11164
+ selectIdentifier: selectIdentifier16,
11165
+ selectDisplayName: selectDisplayName16,
11166
+ verbose
11167
+ });
11168
+ }
11169
+ const target = createWebhookEngineDataSource({ client });
11170
+ await syncEngine({
11171
+ source,
11172
+ target,
11173
+ mode,
11174
+ whatIf,
11175
+ allowEmptySource,
11176
+ log: createSyncEngineConsoleLogger({ diffMode }),
11177
+ compareContents: compareWebhooks
11178
+ });
11179
+ }
11180
+ };
11181
+
11196
11182
  // src/commands/sync/commands/push.ts
11197
11183
  var SyncPushModule = {
11198
11184
  command: "push",
@@ -11408,7 +11394,19 @@ var SyncCommand = {
11408
11394
  describe: "Uniform Sync commands",
11409
11395
  builder: (yargs36) => yargs36.command(SyncPullModule).command(SyncPushModule).demandCommand(),
11410
11396
  handler: () => {
11411
- yargs34.showHelp();
11397
+ yargs33.showHelp();
11398
+ }
11399
+ };
11400
+
11401
+ // src/commands/webhook/index.ts
11402
+ import yargs34 from "yargs";
11403
+ var WebhookCommand = {
11404
+ command: "webhook <command>",
11405
+ aliases: ["wh"],
11406
+ describe: "Commands for webhooks",
11407
+ builder: (yargs36) => yargs36.command(WebhookPullModule).command(WebhookPushModule).demandCommand(),
11408
+ handler: () => {
11409
+ yargs34.help();
11412
11410
  }
11413
11411
  };
11414
11412
 
@@ -11667,4 +11665,4 @@ yarggery.option("verbose", {
11667
11665
  describe: "Include verbose logging",
11668
11666
  default: false,
11669
11667
  type: "boolean"
11670
- }).scriptName("uniform").config(defaultConfig2).config("config", "Specify a custom Uniform CLI config file", (configPath) => loadConfig(configPath)).command(CanvasCommand).command(ContextCommand).command(ProjectMapCommand).command(RedirectCommand).command(SyncCommand).command(NewCmd).command(NewMeshCmd).command(IntegrationCommand).recommendCommands().demandCommand(1, "").strict().help().middleware([checkForUpdateMiddleware, checkLocalDepsVersions]).parse();
11668
+ }).scriptName("uniform").config(defaultConfig2).config("config", "Specify a custom Uniform CLI config file", (configPath) => loadConfig(configPath)).command(CanvasCommand).command(ContextCommand).command(ProjectMapCommand).command(RedirectCommand).command(WebhookCommand).command(SyncCommand).command(NewCmd).command(NewMeshCmd).command(IntegrationCommand).recommendCommands().demandCommand(1, "").strict().help().middleware([checkForUpdateMiddleware, checkLocalDepsVersions]).parse();