@salesforce/b2c-cli 1.12.0 → 1.14.1

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 (53) hide show
  1. package/dist/commands/ecdn/firewall/create.d.ts +44 -0
  2. package/dist/commands/ecdn/firewall/create.js +111 -0
  3. package/dist/commands/ecdn/firewall/create.js.map +1 -0
  4. package/dist/commands/ecdn/firewall/delete.d.ts +39 -0
  5. package/dist/commands/ecdn/firewall/delete.js +64 -0
  6. package/dist/commands/ecdn/firewall/delete.js.map +1 -0
  7. package/dist/commands/ecdn/firewall/get.d.ts +39 -0
  8. package/dist/commands/ecdn/firewall/get.js +66 -0
  9. package/dist/commands/ecdn/firewall/get.js.map +1 -0
  10. package/dist/commands/ecdn/firewall/list.d.ts +43 -0
  11. package/dist/commands/ecdn/firewall/list.js +103 -0
  12. package/dist/commands/ecdn/firewall/list.js.map +1 -0
  13. package/dist/commands/ecdn/firewall/reorder.d.ts +49 -0
  14. package/dist/commands/ecdn/firewall/reorder.js +135 -0
  15. package/dist/commands/ecdn/firewall/reorder.js.map +1 -0
  16. package/dist/commands/ecdn/firewall/update.d.ts +43 -0
  17. package/dist/commands/ecdn/firewall/update.js +106 -0
  18. package/dist/commands/ecdn/firewall/update.js.map +1 -0
  19. package/dist/commands/ecdn/rate-limit/create.d.ts +49 -0
  20. package/dist/commands/ecdn/rate-limit/create.js +158 -0
  21. package/dist/commands/ecdn/rate-limit/create.js.map +1 -0
  22. package/dist/commands/ecdn/rate-limit/delete.d.ts +39 -0
  23. package/dist/commands/ecdn/rate-limit/delete.js +61 -0
  24. package/dist/commands/ecdn/rate-limit/delete.js.map +1 -0
  25. package/dist/commands/ecdn/rate-limit/get.d.ts +39 -0
  26. package/dist/commands/ecdn/rate-limit/get.js +73 -0
  27. package/dist/commands/ecdn/rate-limit/get.js.map +1 -0
  28. package/dist/commands/ecdn/rate-limit/list.d.ts +41 -0
  29. package/dist/commands/ecdn/rate-limit/list.js +108 -0
  30. package/dist/commands/ecdn/rate-limit/list.js.map +1 -0
  31. package/dist/commands/ecdn/rate-limit/update.d.ts +50 -0
  32. package/dist/commands/ecdn/rate-limit/update.js +186 -0
  33. package/dist/commands/ecdn/rate-limit/update.js.map +1 -0
  34. package/dist/commands/job/import.d.ts +21 -2
  35. package/dist/commands/job/import.js +183 -45
  36. package/dist/commands/job/import.js.map +1 -1
  37. package/dist/commands/mrt/bundle/deploy.d.ts +2 -2
  38. package/dist/commands/mrt/bundle/deploy.js +2 -4
  39. package/dist/commands/mrt/bundle/deploy.js.map +1 -1
  40. package/dist/commands/mrt/bundle/save.d.ts +37 -0
  41. package/dist/commands/mrt/bundle/save.js +116 -0
  42. package/dist/commands/mrt/bundle/save.js.map +1 -0
  43. package/dist/hooks/sfnext-jit-install.d.ts +15 -0
  44. package/dist/hooks/sfnext-jit-install.js +23 -0
  45. package/dist/hooks/sfnext-jit-install.js.map +1 -0
  46. package/dist/hooks/sfnext-local-override.d.ts +3 -0
  47. package/dist/hooks/sfnext-local-override.js +65 -0
  48. package/dist/hooks/sfnext-local-override.js.map +1 -0
  49. package/dist/utils/logs/filter.d.ts +1 -40
  50. package/dist/utils/logs/filter.js +1 -106
  51. package/dist/utils/logs/filter.js.map +1 -1
  52. package/oclif.manifest.json +5752 -2126
  53. package/package.json +17 -4
@@ -0,0 +1,135 @@
1
+ /*
2
+ * Copyright (c) 2025, Salesforce, Inc.
3
+ * SPDX-License-Identifier: Apache-2
4
+ * For full license text, see the license.txt file in the repo root or http://www.apache.org/licenses/LICENSE-2.0
5
+ */
6
+ import { Flags } from '@oclif/core';
7
+ import { readFileSync } from 'node:fs';
8
+ import { EcdnZoneCommand, formatApiError } from '../../../utils/ecdn/index.js';
9
+ import { t, withDocs } from '../../../i18n/index.js';
10
+ export default class EcdnFirewallReorder extends EcdnZoneCommand {
11
+ static description = withDocs(t('commands.ecdn.firewall.reorder.description', 'Update the evaluation order of all custom firewall rules'), '/cli/ecdn.html#b2c-ecdn-firewall-reorder');
12
+ static enableJsonFlag = true;
13
+ static examples = [
14
+ '<%= config.bin %> <%= command.id %> --tenant-id zzxy_prd --zone my-zone --rule-ids ffffe61cf25e4ec49c34b029ff3060f7,2c0fc9fa937b11eaa1b71c4d701ab86e',
15
+ '<%= config.bin %> <%= command.id %> --tenant-id zzxy_prd --zone my-zone --rule-ids-file ./order.json',
16
+ ];
17
+ static flags = {
18
+ ...EcdnZoneCommand.baseFlags,
19
+ 'rule-ids': Flags.string({
20
+ description: t('flags.ruleIds.description', 'Comma-separated list of rule IDs in the desired order'),
21
+ exclusive: ['rule-ids-file'],
22
+ }),
23
+ 'rule-ids-file': Flags.string({
24
+ description: t('flags.ruleIdsFile.description', 'Path to a JSON file containing a string array of rule IDs in the desired order'),
25
+ exclusive: ['rule-ids'],
26
+ }),
27
+ force: Flags.boolean({
28
+ char: 'f',
29
+ description: t('flags.force.description', 'Skip confirmation prompt'),
30
+ default: false,
31
+ }),
32
+ };
33
+ async run() {
34
+ // Reordering changes which rules fire first; treat as destructive so it
35
+ // routes through the same safety guard as delete and other rule mutations.
36
+ this.assertDestructiveOperationAllowed('reorder custom firewall rules');
37
+ this.requireOAuthCredentials();
38
+ const zoneId = await this.resolveZoneId();
39
+ const ruleIds = this.parseRuleIds();
40
+ if (!this.flags.force && !this.jsonEnabled()) {
41
+ this.warn(t('commands.ecdn.firewall.reorder.warning', 'Reordering custom firewall rules changes traffic behavior. Use --force to confirm.'));
42
+ return { rules: [], total: 0 };
43
+ }
44
+ if (!this.jsonEnabled()) {
45
+ this.log(t('commands.ecdn.firewall.reorder.updating', 'Reordering {{count}} custom firewall rule(s)...', {
46
+ count: ruleIds.length,
47
+ }));
48
+ }
49
+ const body = { ruleIds };
50
+ const client = this.getCdnZonesRwClient();
51
+ const organizationId = this.getOrganizationId();
52
+ const { data, error } = await client.PATCH('/organizations/{organizationId}/zones/{zoneId}/firewall-custom/rules', {
53
+ params: { path: { organizationId, zoneId } },
54
+ body,
55
+ });
56
+ if (error) {
57
+ this.error(t('commands.ecdn.firewall.reorder.error', 'Failed to reorder custom firewall rules: {{message}}', {
58
+ message: formatApiError(error),
59
+ }));
60
+ }
61
+ const rules = data?.data ?? [];
62
+ const output = { rules, total: rules.length };
63
+ if (this.jsonEnabled()) {
64
+ return output;
65
+ }
66
+ this.log('');
67
+ this.log(t('commands.ecdn.firewall.reorder.success', 'Custom firewall rules reordered. New order ({{count}}):', {
68
+ count: rules.length,
69
+ }));
70
+ for (const [index, rule] of rules.entries()) {
71
+ this.log(` ${index + 1}. ${rule.ruleId} ${rule.description}`);
72
+ }
73
+ return output;
74
+ }
75
+ /**
76
+ * Resolve the desired ordering from either --rule-ids (csv) or
77
+ * --rule-ids-file (path to a JSON array). Centralizing this here keeps run()
78
+ * focused on the API call and makes the inputs easy to validate uniformly.
79
+ */
80
+ parseRuleIds() {
81
+ const csv = this.flags['rule-ids'];
82
+ const file = this.flags['rule-ids-file'];
83
+ if (!csv && !file) {
84
+ this.error(t('commands.ecdn.firewall.reorder.idsRequired', 'Provide --rule-ids or --rule-ids-file with the desired order.'));
85
+ }
86
+ const ids = csv
87
+ ? csv
88
+ .split(',')
89
+ .map((value) => value.trim())
90
+ .filter(Boolean)
91
+ : this.readRuleIdsFile(file);
92
+ if (ids.length === 0) {
93
+ this.error(t('commands.ecdn.firewall.reorder.idsEmpty', 'At least one rule ID is required.'));
94
+ }
95
+ const seen = new Set();
96
+ for (const id of ids) {
97
+ if (seen.has(id)) {
98
+ this.error(t('commands.ecdn.firewall.reorder.idsDuplicate', 'Duplicate rule ID in order list: {{id}}', { id }));
99
+ }
100
+ seen.add(id);
101
+ }
102
+ return ids;
103
+ }
104
+ readRuleIdsFile(filePath) {
105
+ let raw;
106
+ try {
107
+ raw = readFileSync(filePath, 'utf8');
108
+ }
109
+ catch (error) {
110
+ const message = error instanceof Error ? error.message : String(error);
111
+ this.error(t('commands.ecdn.firewall.reorder.fileReadError', 'Failed to read rule IDs file {{path}}: {{message}}', {
112
+ path: filePath,
113
+ message,
114
+ }));
115
+ }
116
+ let parsed;
117
+ try {
118
+ parsed = JSON.parse(raw);
119
+ }
120
+ catch (error) {
121
+ const message = error instanceof Error ? error.message : String(error);
122
+ this.error(t('commands.ecdn.firewall.reorder.fileParseError', 'Rule IDs file {{path}} is not valid JSON: {{message}}', {
123
+ path: filePath,
124
+ message,
125
+ }));
126
+ }
127
+ if (!Array.isArray(parsed) || !parsed.every((value) => typeof value === 'string')) {
128
+ this.error(t('commands.ecdn.firewall.reorder.fileShapeError', 'Rule IDs file {{path}} must be a JSON array of strings.', {
129
+ path: filePath,
130
+ }));
131
+ }
132
+ return parsed.map((value) => value.trim()).filter(Boolean);
133
+ }
134
+ }
135
+ //# sourceMappingURL=reorder.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"reorder.js","sourceRoot":"","sources":["../../../../src/commands/ecdn/firewall/reorder.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AACH,OAAO,EAAC,KAAK,EAAC,MAAM,aAAa,CAAC;AAClC,OAAO,EAAC,YAAY,EAAC,MAAM,SAAS,CAAC;AAErC,OAAO,EAAC,eAAe,EAAE,cAAc,EAAC,MAAM,8BAA8B,CAAC;AAC7E,OAAO,EAAC,CAAC,EAAE,QAAQ,EAAC,MAAM,wBAAwB,CAAC;AAUnD,MAAM,CAAC,OAAO,OAAO,mBAAoB,SAAQ,eAA2C;IAC1F,MAAM,CAAC,WAAW,GAAG,QAAQ,CAC3B,CAAC,CAAC,4CAA4C,EAAE,0DAA0D,CAAC,EAC3G,0CAA0C,CAC3C,CAAC;IAEF,MAAM,CAAC,cAAc,GAAG,IAAI,CAAC;IAE7B,MAAM,CAAC,QAAQ,GAAG;QAChB,sJAAsJ;QACtJ,sGAAsG;KACvG,CAAC;IAEF,MAAM,CAAC,KAAK,GAAG;QACb,GAAG,eAAe,CAAC,SAAS;QAC5B,UAAU,EAAE,KAAK,CAAC,MAAM,CAAC;YACvB,WAAW,EAAE,CAAC,CAAC,2BAA2B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AC,KAAK,CACR,CAAC,CAAC,8CAA8C,EAAE,oDAAoD,EAAE;gBACtG,IAAI,EAAE,QAAQ;gBACd,OAAO;aACR,CAAC,CACH,CAAC;QACJ,CAAC;QAED,IAAI,MAAe,CAAC;QACpB,IAAI,CAAC;YACH,MAAM,GAAG,IAAI,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC;QAC3B,CAAC;QAAC,OAAO,KAAK,EAAE,CAAC;YACf,MAAM,OAAO,GAAG,KAAK,YAAY,KAAK,CAAC,CAAC,CAAC,KAAK,CAAC,OAAO,CAAC,CAAC,CAAC,MAAM,CAAC,KAAK,CAAC,CAAC;YACvE,IAAI,CAAC,KAAK,CACR,CAAC,CAAC,+CAA+C,EAAE,uDAAuD,EAAE;gBAC1G,IAAI,EAAE,QAAQ;gBACd,OAAO;aACR,CAAC,CACH,CAAC;QACJ,CAAC;QAED,IAAI,CAAC,KAAK,CAAC,OAAO,CAAC,MAAM,CAAC,IAAI,CAAC,MAAM,CAAC,KAAK,CAAC,CAAC,KAAK,EAAE,EAAE,CAAC,OAAO,KAAK,KAAK,QAAQ,CAAC,EAAE,CAAC;YAClF,IAAI,CAAC,KAAK,CACR,CAAC,CAAC,+CAA+C,EAAE,yDAAyD,EAAE;gBAC5G,IAAI,EAAE,QAAQ;aACf,CAAC,CACH,CAAC;QACJ,CAAC;QAED,OAAQ,MAAmB,CAAC,GAAG,CAAC,CAAC,KAAK,EAAE,EAAE,CAAC,KAAK,CAAC,IAAI,EAAE,CAAC,CAAC,MAAM,CAAC,OAAO,CAAC,CAAC;IAC3E,CAAC"}
@@ -0,0 +1,43 @@
1
+ import type { CdnZonesComponents } from '@salesforce/b2c-tooling-sdk/clients';
2
+ import { EcdnZoneCommand } from '../../../utils/ecdn/index.js';
3
+ type CustomRule = CdnZonesComponents['schemas']['CustomRule'];
4
+ interface UpdateOutput {
5
+ rule: CustomRule;
6
+ }
7
+ export default class EcdnFirewallUpdate extends EcdnZoneCommand<typeof EcdnFirewallUpdate> {
8
+ static description: string;
9
+ static enableJsonFlag: boolean;
10
+ static examples: string[];
11
+ static flags: {
12
+ 'rule-id': import("@oclif/core/interfaces").OptionFlag<string, import("@oclif/core/interfaces").CustomOptions>;
13
+ description: import("@oclif/core/interfaces").OptionFlag<string | undefined, import("@oclif/core/interfaces").CustomOptions>;
14
+ expression: import("@oclif/core/interfaces").OptionFlag<string | undefined, import("@oclif/core/interfaces").CustomOptions>;
15
+ actions: import("@oclif/core/interfaces").OptionFlag<string | undefined, import("@oclif/core/interfaces").CustomOptions>;
16
+ enabled: import("@oclif/core/interfaces").BooleanFlag<boolean>;
17
+ zone: import("@oclif/core/interfaces").OptionFlag<string, import("@oclif/core/interfaces").CustomOptions>;
18
+ 'client-id': import("@oclif/core/interfaces").OptionFlag<string, import("@oclif/core/interfaces").CustomOptions>;
19
+ 'client-secret': import("@oclif/core/interfaces").OptionFlag<string, import("@oclif/core/interfaces").CustomOptions>;
20
+ 'auth-scope': import("@oclif/core/interfaces").OptionFlag<string[] | undefined, import("@oclif/core/interfaces").CustomOptions>;
21
+ 'short-code': import("@oclif/core/interfaces").OptionFlag<string | undefined, import("@oclif/core/interfaces").CustomOptions>;
22
+ 'tenant-id': import("@oclif/core/interfaces").OptionFlag<string | undefined, import("@oclif/core/interfaces").CustomOptions>;
23
+ 'auth-methods': import("@oclif/core/interfaces").OptionFlag<string[] | undefined, import("@oclif/core/interfaces").CustomOptions>;
24
+ 'user-auth': import("@oclif/core/interfaces").BooleanFlag<boolean>;
25
+ 'account-manager-host': import("@oclif/core/interfaces").OptionFlag<string, import("@oclif/core/interfaces").CustomOptions>;
26
+ 'jwt-cert': import("@oclif/core/interfaces").OptionFlag<string | undefined, import("@oclif/core/interfaces").CustomOptions>;
27
+ 'jwt-key': import("@oclif/core/interfaces").OptionFlag<string | undefined, import("@oclif/core/interfaces").CustomOptions>;
28
+ 'jwt-passphrase': import("@oclif/core/interfaces").OptionFlag<string | undefined, import("@oclif/core/interfaces").CustomOptions>;
29
+ 'log-level': import("@oclif/core/interfaces").OptionFlag<"trace" | "debug" | "info" | "warn" | "error" | "silent" | undefined, import("@oclif/core/interfaces").CustomOptions>;
30
+ debug: import("@oclif/core/interfaces").BooleanFlag<boolean>;
31
+ json: import("@oclif/core/interfaces").BooleanFlag<boolean>;
32
+ jsonl: import("@oclif/core/interfaces").BooleanFlag<boolean>;
33
+ lang: import("@oclif/core/interfaces").OptionFlag<string | undefined, import("@oclif/core/interfaces").CustomOptions>;
34
+ config: import("@oclif/core/interfaces").OptionFlag<string | undefined, import("@oclif/core/interfaces").CustomOptions>;
35
+ instance: import("@oclif/core/interfaces").OptionFlag<string | undefined, import("@oclif/core/interfaces").CustomOptions>;
36
+ 'project-directory': import("@oclif/core/interfaces").OptionFlag<string, import("@oclif/core/interfaces").CustomOptions>;
37
+ 'extra-query': import("@oclif/core/interfaces").OptionFlag<string | undefined, import("@oclif/core/interfaces").CustomOptions>;
38
+ 'extra-body': import("@oclif/core/interfaces").OptionFlag<string | undefined, import("@oclif/core/interfaces").CustomOptions>;
39
+ 'extra-headers': import("@oclif/core/interfaces").OptionFlag<string | undefined, import("@oclif/core/interfaces").CustomOptions>;
40
+ };
41
+ run(): Promise<UpdateOutput>;
42
+ }
43
+ export {};
@@ -0,0 +1,106 @@
1
+ /*
2
+ * Copyright (c) 2025, Salesforce, Inc.
3
+ * SPDX-License-Identifier: Apache-2
4
+ * For full license text, see the license.txt file in the repo root or http://www.apache.org/licenses/LICENSE-2.0
5
+ */
6
+ import { Flags } from '@oclif/core';
7
+ import cliui from 'cliui';
8
+ import { EcdnZoneCommand, formatApiError } from '../../../utils/ecdn/index.js';
9
+ import { t, withDocs } from '../../../i18n/index.js';
10
+ export default class EcdnFirewallUpdate extends EcdnZoneCommand {
11
+ static description = withDocs(t('commands.ecdn.firewall.update.description', 'Update a custom firewall rule for a zone'), '/cli/ecdn.html#b2c-ecdn-firewall-update');
12
+ static enableJsonFlag = true;
13
+ static examples = [
14
+ '<%= config.bin %> <%= command.id %> --tenant-id zzxy_prd --zone my-zone --rule-id 2c0fc9fa937b11eaa1b71c4d701ab86e --description "Updated copy"',
15
+ '<%= config.bin %> <%= command.id %> --tenant-id zzxy_prd --zone my-zone --rule-id 2c0fc9fa937b11eaa1b71c4d701ab86e --actions managed_challenge --no-enabled',
16
+ ];
17
+ static flags = {
18
+ ...EcdnZoneCommand.baseFlags,
19
+ 'rule-id': Flags.string({
20
+ description: t('flags.ruleId.description', 'Custom firewall rule ID'),
21
+ required: true,
22
+ }),
23
+ description: Flags.string({
24
+ description: t('flags.description.description', 'Rule description'),
25
+ }),
26
+ expression: Flags.string({
27
+ description: t('flags.expression.description', 'Expression that determines when this rule applies'),
28
+ }),
29
+ actions: Flags.string({
30
+ description: t('flags.actions.description', 'Comma-separated list of actions applied by the rule'),
31
+ }),
32
+ enabled: Flags.boolean({
33
+ description: t('flags.enabled.description', 'Whether the rule is enabled'),
34
+ allowNo: true,
35
+ }),
36
+ };
37
+ async run() {
38
+ this.requireOAuthCredentials();
39
+ const zoneId = await this.resolveZoneId();
40
+ const ruleId = this.flags['rule-id'];
41
+ const description = this.flags.description;
42
+ const expression = this.flags.expression;
43
+ const actionsRaw = this.flags.actions;
44
+ const enabled = this.flags.enabled;
45
+ const hasUpdates = [description, expression, actionsRaw, enabled].some((value) => value !== undefined);
46
+ if (!hasUpdates) {
47
+ this.error(t('commands.ecdn.firewall.update.noChanges', 'Provide at least one field to update.'));
48
+ }
49
+ if (!this.jsonEnabled()) {
50
+ this.log(t('commands.ecdn.firewall.update.updating', 'Updating custom firewall rule {{id}}...', { id: ruleId }));
51
+ }
52
+ const body = {};
53
+ if (description !== undefined) {
54
+ body.description = description;
55
+ }
56
+ if (expression !== undefined) {
57
+ body.expression = expression;
58
+ }
59
+ if (actionsRaw !== undefined) {
60
+ const actions = actionsRaw
61
+ .split(',')
62
+ .map((value) => value.trim())
63
+ .filter(Boolean);
64
+ if (actions.length === 0) {
65
+ this.error(t('commands.ecdn.firewall.update.actionsRequired', 'At least one action must be provided.'));
66
+ }
67
+ body.actions = actions;
68
+ }
69
+ if (enabled !== undefined) {
70
+ body.enabled = enabled;
71
+ }
72
+ const client = this.getCdnZonesRwClient();
73
+ const organizationId = this.getOrganizationId();
74
+ const { data, error } = await client.PATCH('/organizations/{organizationId}/zones/{zoneId}/firewall-custom/rules/{ruleId}', {
75
+ params: {
76
+ path: { organizationId, zoneId, ruleId },
77
+ },
78
+ body,
79
+ });
80
+ if (error) {
81
+ this.error(t('commands.ecdn.firewall.update.error', 'Failed to update custom firewall rule: {{message}}', {
82
+ message: formatApiError(error),
83
+ }));
84
+ }
85
+ const rule = data?.data;
86
+ if (!rule) {
87
+ this.error(t('commands.ecdn.firewall.update.noData', 'No custom firewall rule data returned from API'));
88
+ }
89
+ const output = { rule };
90
+ if (this.jsonEnabled()) {
91
+ return output;
92
+ }
93
+ const ui = cliui({ width: process.stdout.columns || 80 });
94
+ const labelWidth = 18;
95
+ ui.div('');
96
+ ui.div({ text: t('commands.ecdn.firewall.update.success', 'Custom firewall rule updated successfully!') });
97
+ ui.div('');
98
+ ui.div({ text: 'Rule ID:', width: labelWidth }, { text: rule.ruleId });
99
+ ui.div({ text: 'Description:', width: labelWidth }, { text: rule.description });
100
+ ui.div({ text: 'Actions:', width: labelWidth }, { text: rule.actions?.join(', ') ?? '-' });
101
+ ui.div({ text: 'Enabled:', width: labelWidth }, { text: rule.enabled ? 'yes' : 'no' });
102
+ this.log(ui.toString());
103
+ return output;
104
+ }
105
+ }
106
+ //# sourceMappingURL=update.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"update.js","sourceRoot":"","sources":["../../../../src/commands/ecdn/firewall/update.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AACH,OAAO,EAAC,KAAK,EAAC,MAAM,aAAa,CAAC;AAClC,OAAO,KAAK,MAAM,OAAO,CAAC;AAE1B,OAAO,EAAC,eAAe,EAAE,cAAc,EAAC,MAAM,8BAA8B,CAAC;AAC7E,OAAO,EAAC,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,CAAC,GAAG,CAAC,EAAC,IAAI,EAAE,CAAC,CAAC,uCAAuC,EAAE,4CAA4C,CAAC,EAAC,CAAC,CAAC;QACzG,EAAE,CAAC,GAAG,CAAC,EAAE,CAAC,CAAC;QACX,EAAE,CAAC,GAAG,CAAC,EAAC,IAAI,EAAE,UAAU,EAAE,KAAK,EAAE,UAAU,EAAC,EAAE,EAAC,IAAI,EAAE,IAAI,CAAC,MAAM,EAAC,CAAC,CAAC;QACnE,EAAE,CAAC,GAAG,CAAC,EAAC,IAAI,EAAE,cAAc,EAAE,KAAK,EAAE,UAAU,EAAC,EAAE,EAAC,IAAI,EAAE,IAAI,CAAC,WAAW,EAAC,CAAC,CAAC;QAC5E,EAAE,CAAC,GAAG,CAAC,EAAC,IAAI,EAAE,UAAU,EAAE,KAAK,EAAE,UAAU,EAAC,EAAE,EAAC,IAAI,EAAE,IAAI,CAAC,OAAO,EAAE,IAAI,CAAC,IAAI,CAAC,IAAI,GAAG,EAAC,CAAC,CAAC;QACvF,EAAE,CAAC,GAAG,CAAC,EAAC,IAAI,EAAE,UAAU,EAAE,KAAK,EAAE,UAAU,EAAC,EAAE,EAAC,IAAI,EAAE,IAAI,CAAC,OAAO,CAAC,CAAC,CAAC,KAAK,CAAC,CAAC,CAAC,IAAI,EAAC,CAAC,CAAC;QAEnF,IAAI,CAAC,GAAG,CAAC,EAAE,CAAC,QAAQ,EAAE,CAAC,CAAC;QAExB,OAAO,MAAM,CAAC;IAChB,CAAC"}
@@ -0,0 +1,49 @@
1
+ import type { CdnZonesComponents } from '@salesforce/b2c-tooling-sdk/clients';
2
+ import { EcdnZoneCommand } from '../../../utils/ecdn/index.js';
3
+ type RateLimitingRule = CdnZonesComponents['schemas']['RateLimitingRule'];
4
+ interface CreateOutput {
5
+ rule: RateLimitingRule;
6
+ }
7
+ export default class EcdnRateLimitCreate extends EcdnZoneCommand<typeof EcdnRateLimitCreate> {
8
+ static description: string;
9
+ static enableJsonFlag: boolean;
10
+ static examples: string[];
11
+ static flags: {
12
+ description: import("@oclif/core/interfaces").OptionFlag<string, import("@oclif/core/interfaces").CustomOptions>;
13
+ expression: import("@oclif/core/interfaces").OptionFlag<string, import("@oclif/core/interfaces").CustomOptions>;
14
+ characteristics: import("@oclif/core/interfaces").OptionFlag<string, import("@oclif/core/interfaces").CustomOptions>;
15
+ action: import("@oclif/core/interfaces").OptionFlag<string, import("@oclif/core/interfaces").CustomOptions>;
16
+ period: import("@oclif/core/interfaces").OptionFlag<number, import("@oclif/core/interfaces").CustomOptions>;
17
+ 'requests-per-period': import("@oclif/core/interfaces").OptionFlag<number, import("@oclif/core/interfaces").CustomOptions>;
18
+ 'mitigation-timeout': import("@oclif/core/interfaces").OptionFlag<number, import("@oclif/core/interfaces").CustomOptions>;
19
+ 'counting-expression': import("@oclif/core/interfaces").OptionFlag<string | undefined, import("@oclif/core/interfaces").CustomOptions>;
20
+ enabled: import("@oclif/core/interfaces").BooleanFlag<boolean>;
21
+ 'position-before': import("@oclif/core/interfaces").OptionFlag<string | undefined, import("@oclif/core/interfaces").CustomOptions>;
22
+ 'position-after': import("@oclif/core/interfaces").OptionFlag<string | undefined, import("@oclif/core/interfaces").CustomOptions>;
23
+ zone: import("@oclif/core/interfaces").OptionFlag<string, import("@oclif/core/interfaces").CustomOptions>;
24
+ 'client-id': import("@oclif/core/interfaces").OptionFlag<string, import("@oclif/core/interfaces").CustomOptions>;
25
+ 'client-secret': import("@oclif/core/interfaces").OptionFlag<string, import("@oclif/core/interfaces").CustomOptions>;
26
+ 'auth-scope': import("@oclif/core/interfaces").OptionFlag<string[] | undefined, import("@oclif/core/interfaces").CustomOptions>;
27
+ 'short-code': import("@oclif/core/interfaces").OptionFlag<string | undefined, import("@oclif/core/interfaces").CustomOptions>;
28
+ 'tenant-id': import("@oclif/core/interfaces").OptionFlag<string | undefined, import("@oclif/core/interfaces").CustomOptions>;
29
+ 'auth-methods': import("@oclif/core/interfaces").OptionFlag<string[] | undefined, import("@oclif/core/interfaces").CustomOptions>;
30
+ 'user-auth': import("@oclif/core/interfaces").BooleanFlag<boolean>;
31
+ 'account-manager-host': import("@oclif/core/interfaces").OptionFlag<string, import("@oclif/core/interfaces").CustomOptions>;
32
+ 'jwt-cert': import("@oclif/core/interfaces").OptionFlag<string | undefined, import("@oclif/core/interfaces").CustomOptions>;
33
+ 'jwt-key': import("@oclif/core/interfaces").OptionFlag<string | undefined, import("@oclif/core/interfaces").CustomOptions>;
34
+ 'jwt-passphrase': import("@oclif/core/interfaces").OptionFlag<string | undefined, import("@oclif/core/interfaces").CustomOptions>;
35
+ 'log-level': import("@oclif/core/interfaces").OptionFlag<"trace" | "debug" | "info" | "warn" | "error" | "silent" | undefined, import("@oclif/core/interfaces").CustomOptions>;
36
+ debug: import("@oclif/core/interfaces").BooleanFlag<boolean>;
37
+ json: import("@oclif/core/interfaces").BooleanFlag<boolean>;
38
+ jsonl: import("@oclif/core/interfaces").BooleanFlag<boolean>;
39
+ lang: import("@oclif/core/interfaces").OptionFlag<string | undefined, import("@oclif/core/interfaces").CustomOptions>;
40
+ config: import("@oclif/core/interfaces").OptionFlag<string | undefined, import("@oclif/core/interfaces").CustomOptions>;
41
+ instance: import("@oclif/core/interfaces").OptionFlag<string | undefined, import("@oclif/core/interfaces").CustomOptions>;
42
+ 'project-directory': import("@oclif/core/interfaces").OptionFlag<string, import("@oclif/core/interfaces").CustomOptions>;
43
+ 'extra-query': import("@oclif/core/interfaces").OptionFlag<string | undefined, import("@oclif/core/interfaces").CustomOptions>;
44
+ 'extra-body': import("@oclif/core/interfaces").OptionFlag<string | undefined, import("@oclif/core/interfaces").CustomOptions>;
45
+ 'extra-headers': import("@oclif/core/interfaces").OptionFlag<string | undefined, import("@oclif/core/interfaces").CustomOptions>;
46
+ };
47
+ run(): Promise<CreateOutput>;
48
+ }
49
+ export {};
@@ -0,0 +1,158 @@
1
+ /*
2
+ * Copyright (c) 2025, Salesforce, Inc.
3
+ * SPDX-License-Identifier: Apache-2
4
+ * For full license text, see the license.txt file in the repo root or http://www.apache.org/licenses/LICENSE-2.0
5
+ */
6
+ import { Flags } from '@oclif/core';
7
+ import cliui from 'cliui';
8
+ import { EcdnZoneCommand, formatApiError } from '../../../utils/ecdn/index.js';
9
+ import { t, withDocs } from '../../../i18n/index.js';
10
+ const VALID_PERIODS = [10, 60, 120, 300, 600];
11
+ const VALID_MITIGATION_TIMEOUTS = [0, 60, 120, 300, 600, 3600, 86_400];
12
+ export default class EcdnRateLimitCreate extends EcdnZoneCommand {
13
+ static description = withDocs(t('commands.ecdn.rate-limit.create.description', 'Create a rate limiting rule for a zone'), '/cli/ecdn.html#b2c-ecdn-rate-limit-create');
14
+ static enableJsonFlag = true;
15
+ static examples = [
16
+ `<%= config.bin %> <%= command.id %> --tenant-id zzxy_prd --zone my-zone --description "Rate limit /checkout" --expression '(http.request.uri.path matches "^/checkout")' --characteristics cf.unique_visitor_id --action block --period 60 --requests-per-period 50 --mitigation-timeout 600`,
17
+ `<%= config.bin %> <%= command.id %> --tenant-id zzxy_prd --zone my-zone --description "Log spikes" --expression '(http.request.uri.path matches "^/api")' --characteristics cf.colo.id --action log --period 60 --requests-per-period 100 --mitigation-timeout 0 --enabled false`,
18
+ ];
19
+ static flags = {
20
+ ...EcdnZoneCommand.baseFlags,
21
+ description: Flags.string({
22
+ description: t('flags.description.description', 'Rule description'),
23
+ required: true,
24
+ }),
25
+ expression: Flags.string({
26
+ description: t('flags.expression.description', 'Expression for when to evaluate this rule'),
27
+ required: true,
28
+ }),
29
+ characteristics: Flags.string({
30
+ description: t('flags.characteristics.description', 'Comma-separated characteristics used to group requests'),
31
+ required: true,
32
+ }),
33
+ action: Flags.string({
34
+ description: t('flags.action.description', 'Action applied when the rule threshold is exceeded'),
35
+ required: true,
36
+ options: ['block', 'managed_challenge', 'js_challenge', 'legacy_captcha', 'log'],
37
+ }),
38
+ period: Flags.integer({
39
+ description: t('flags.period.description', 'Rate limit evaluation period in seconds'),
40
+ required: true,
41
+ }),
42
+ 'requests-per-period': Flags.integer({
43
+ description: t('flags.requestsPerPeriod.description', 'Maximum requests allowed within the period'),
44
+ required: true,
45
+ }),
46
+ 'mitigation-timeout': Flags.integer({
47
+ description: t('flags.mitigationTimeout.description', 'Duration in seconds to apply action after threshold is reached'),
48
+ required: true,
49
+ }),
50
+ 'counting-expression': Flags.string({
51
+ description: t('flags.countingExpression.description', 'Optional expression for what requests to count'),
52
+ }),
53
+ enabled: Flags.boolean({
54
+ description: t('flags.enabled.description', 'Whether the rule is enabled'),
55
+ allowNo: true,
56
+ default: true,
57
+ }),
58
+ 'position-before': Flags.string({
59
+ description: t('flags.positionBefore.description', 'Insert this rule before the specified rule ID'),
60
+ exclusive: ['position-after'],
61
+ }),
62
+ 'position-after': Flags.string({
63
+ description: t('flags.positionAfter.description', 'Insert this rule after the specified rule ID'),
64
+ exclusive: ['position-before'],
65
+ }),
66
+ };
67
+ async run() {
68
+ this.requireOAuthCredentials();
69
+ const zoneId = await this.resolveZoneId();
70
+ const description = this.flags.description;
71
+ const expression = this.flags.expression;
72
+ const characteristicsRaw = this.flags.characteristics;
73
+ const action = this.flags.action;
74
+ const period = this.flags.period;
75
+ const requestsPerPeriod = this.flags['requests-per-period'];
76
+ const mitigationTimeout = this.flags['mitigation-timeout'];
77
+ const countingExpression = this.flags['counting-expression'];
78
+ const enabled = this.flags.enabled;
79
+ const positionBefore = this.flags['position-before'];
80
+ const positionAfter = this.flags['position-after'];
81
+ if (!this.jsonEnabled()) {
82
+ this.log(t('commands.ecdn.rate-limit.create.creating', 'Creating rate limiting rule...'));
83
+ }
84
+ if (!VALID_PERIODS.includes(period)) {
85
+ this.error(t('commands.ecdn.rate-limit.create.invalidPeriod', 'Invalid period: {{period}}. Valid values: {{valid}}.', {
86
+ period: String(period),
87
+ valid: VALID_PERIODS.join(', '),
88
+ }));
89
+ }
90
+ if (!VALID_MITIGATION_TIMEOUTS.includes(mitigationTimeout)) {
91
+ this.error(t('commands.ecdn.rate-limit.create.invalidMitigationTimeout', 'Invalid mitigation timeout: {{timeout}}. Valid values: {{valid}}.', {
92
+ timeout: String(mitigationTimeout),
93
+ valid: VALID_MITIGATION_TIMEOUTS.join(', '),
94
+ }));
95
+ }
96
+ const characteristics = characteristicsRaw
97
+ .split(',')
98
+ .map((value) => value.trim())
99
+ .filter(Boolean);
100
+ if (characteristics.length === 0) {
101
+ this.error(t('commands.ecdn.rate-limit.create.characteristicsRequired', 'At least one characteristic must be provided.'));
102
+ }
103
+ const body = {
104
+ description,
105
+ expression,
106
+ characteristics,
107
+ action,
108
+ period,
109
+ requestsPerPeriod,
110
+ mitigationTimeout,
111
+ enabled,
112
+ };
113
+ if (countingExpression) {
114
+ body.countingExpression = countingExpression;
115
+ }
116
+ if (positionBefore) {
117
+ body.position = { before: positionBefore };
118
+ }
119
+ if (positionAfter) {
120
+ body.position = { after: positionAfter };
121
+ }
122
+ const client = this.getCdnZonesRwClient();
123
+ const organizationId = this.getOrganizationId();
124
+ const { data, error } = await client.POST('/organizations/{organizationId}/zones/{zoneId}/rate-limiting/rules', {
125
+ params: {
126
+ path: { organizationId, zoneId },
127
+ },
128
+ body,
129
+ });
130
+ if (error) {
131
+ this.error(t('commands.ecdn.rate-limit.create.error', 'Failed to create rate limiting rule: {{message}}', {
132
+ message: formatApiError(error),
133
+ }));
134
+ }
135
+ const rule = data?.data;
136
+ if (!rule) {
137
+ this.error(t('commands.ecdn.rate-limit.create.noData', 'No rate limiting rule data returned from API'));
138
+ }
139
+ const output = { rule };
140
+ if (this.jsonEnabled()) {
141
+ return output;
142
+ }
143
+ const ui = cliui({ width: process.stdout.columns || 80 });
144
+ const labelWidth = 22;
145
+ ui.div('');
146
+ ui.div({ text: t('commands.ecdn.rate-limit.create.success', 'Rate limiting rule created successfully!') });
147
+ ui.div('');
148
+ ui.div({ text: 'Rule ID:', width: labelWidth }, { text: rule.ruleId });
149
+ ui.div({ text: 'Description:', width: labelWidth }, { text: rule.description });
150
+ ui.div({ text: 'Action:', width: labelWidth }, { text: rule.action });
151
+ ui.div({ text: 'Period (seconds):', width: labelWidth }, { text: String(rule.period) });
152
+ ui.div({ text: 'Requests Per Period:', width: labelWidth }, { text: String(rule.requestsPerPeriod) });
153
+ ui.div({ text: 'Enabled:', width: labelWidth }, { text: rule.enabled ? 'yes' : 'no' });
154
+ this.log(ui.toString());
155
+ return output;
156
+ }
157
+ }
158
+ //# sourceMappingURL=create.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"create.js","sourceRoot":"","sources":["../../../../src/commands/ecdn/rate-limit/create.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AACH,OAAO,EAAC,KAAK,EAAC,MAAM,aAAa,CAAC;AAClC,OAAO,KAAK,MAAM,OAAO,CAAC;AAE1B,OAAO,EAAC,eAAe,EAAE,cAAc,EAAC,MAAM,8BAA8B,CAAC;AAC7E,OAAO,EAAC,CAAC,EAAE,QAAQ,EAAC,MAAM,wBAAwB,CAAC;AAKnD,MAAM,aAAa,GAAG,CAAC,EAAE,EAAE,EAAE,EAAE,GAAG,EAAE,GAAG,EAAE,GAAG,CAAC,CAAC;AAC9C,MAAM,yBAAyB,GAAG,CAAC,CAAC,EAAE,EAAE,EAAE,GAAG,EAAE,GAAG,EAAE,GAAG,EAAE,IAAI,EAAE,MAAM,CAAC,CAAC;AAMvE,MAAM,CAAC,OAAO,OAAO,mBAAoB,SAAQ,eAA2C;IAC1F,MAAM,CAAC,WAAW,GAAG,QAAQ,CAC3B,CAAC,CAAC,6CAA6C,EAAE,wCAAwC,CAAC,EAC1F,2CAA2C,CAC5C,CAAC;IAEF,MAAM,CAAC,cAAc,GAAG,IAAI,CAAC;IAE7B,MAAM,CAAC,QAAQ,GAAG;QAChB,8RAA8R;QAC9R,kRAAkR;KACnR,CAAC;IAEF,MAAM,CAAC,KAAK,GAAG;QACb,GAAG,eAAe,CAAC,SAAS;QAC5B,WAAW,EAAE,KAAK,CAAC,MAAM,CAAC;YACxB,WAAW,EAAE,CAAC,CAAC,+BAA+B,EAAE,kBAAkB,CAAC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3
+ deleted: boolean;
4
+ ruleId: string;
5
+ }
6
+ export default class EcdnRateLimitDelete extends EcdnZoneCommand<typeof EcdnRateLimitDelete> {
7
+ static description: string;
8
+ static enableJsonFlag: boolean;
9
+ static examples: string[];
10
+ static flags: {
11
+ 'rule-id': import("@oclif/core/interfaces").OptionFlag<string, import("@oclif/core/interfaces").CustomOptions>;
12
+ force: import("@oclif/core/interfaces").BooleanFlag<boolean>;
13
+ zone: import("@oclif/core/interfaces").OptionFlag<string, import("@oclif/core/interfaces").CustomOptions>;
14
+ 'client-id': import("@oclif/core/interfaces").OptionFlag<string, import("@oclif/core/interfaces").CustomOptions>;
15
+ 'client-secret': import("@oclif/core/interfaces").OptionFlag<string, import("@oclif/core/interfaces").CustomOptions>;
16
+ 'auth-scope': import("@oclif/core/interfaces").OptionFlag<string[] | undefined, import("@oclif/core/interfaces").CustomOptions>;
17
+ 'short-code': import("@oclif/core/interfaces").OptionFlag<string | undefined, import("@oclif/core/interfaces").CustomOptions>;
18
+ 'tenant-id': import("@oclif/core/interfaces").OptionFlag<string | undefined, import("@oclif/core/interfaces").CustomOptions>;
19
+ 'auth-methods': import("@oclif/core/interfaces").OptionFlag<string[] | undefined, import("@oclif/core/interfaces").CustomOptions>;
20
+ 'user-auth': import("@oclif/core/interfaces").BooleanFlag<boolean>;
21
+ 'account-manager-host': import("@oclif/core/interfaces").OptionFlag<string, import("@oclif/core/interfaces").CustomOptions>;
22
+ 'jwt-cert': import("@oclif/core/interfaces").OptionFlag<string | undefined, import("@oclif/core/interfaces").CustomOptions>;
23
+ 'jwt-key': import("@oclif/core/interfaces").OptionFlag<string | undefined, import("@oclif/core/interfaces").CustomOptions>;
24
+ 'jwt-passphrase': import("@oclif/core/interfaces").OptionFlag<string | undefined, import("@oclif/core/interfaces").CustomOptions>;
25
+ 'log-level': import("@oclif/core/interfaces").OptionFlag<"trace" | "debug" | "info" | "warn" | "error" | "silent" | undefined, import("@oclif/core/interfaces").CustomOptions>;
26
+ debug: import("@oclif/core/interfaces").BooleanFlag<boolean>;
27
+ json: import("@oclif/core/interfaces").BooleanFlag<boolean>;
28
+ jsonl: import("@oclif/core/interfaces").BooleanFlag<boolean>;
29
+ lang: import("@oclif/core/interfaces").OptionFlag<string | undefined, import("@oclif/core/interfaces").CustomOptions>;
30
+ config: import("@oclif/core/interfaces").OptionFlag<string | undefined, import("@oclif/core/interfaces").CustomOptions>;
31
+ instance: import("@oclif/core/interfaces").OptionFlag<string | undefined, import("@oclif/core/interfaces").CustomOptions>;
32
+ 'project-directory': import("@oclif/core/interfaces").OptionFlag<string, import("@oclif/core/interfaces").CustomOptions>;
33
+ 'extra-query': import("@oclif/core/interfaces").OptionFlag<string | undefined, import("@oclif/core/interfaces").CustomOptions>;
34
+ 'extra-body': import("@oclif/core/interfaces").OptionFlag<string | undefined, import("@oclif/core/interfaces").CustomOptions>;
35
+ 'extra-headers': import("@oclif/core/interfaces").OptionFlag<string | undefined, import("@oclif/core/interfaces").CustomOptions>;
36
+ };
37
+ run(): Promise<DeleteOutput>;
38
+ }
39
+ export {};
@@ -0,0 +1,61 @@
1
+ /*
2
+ * Copyright (c) 2025, Salesforce, Inc.
3
+ * SPDX-License-Identifier: Apache-2
4
+ * For full license text, see the license.txt file in the repo root or http://www.apache.org/licenses/LICENSE-2.0
5
+ */
6
+ import { Flags } from '@oclif/core';
7
+ import { EcdnZoneCommand, formatApiError } from '../../../utils/ecdn/index.js';
8
+ import { t, withDocs } from '../../../i18n/index.js';
9
+ export default class EcdnRateLimitDelete extends EcdnZoneCommand {
10
+ static description = withDocs(t('commands.ecdn.rate-limit.delete.description', 'Delete a rate limiting rule for a zone'), '/cli/ecdn.html#b2c-ecdn-rate-limit-delete');
11
+ static enableJsonFlag = true;
12
+ static examples = [
13
+ '<%= config.bin %> <%= command.id %> --tenant-id zzxy_prd --zone my-zone --rule-id 2c0fc9fa937b11eaa1b71c4d701ab86e',
14
+ '<%= config.bin %> <%= command.id %> --tenant-id zzxy_prd --zone my-zone --rule-id 2c0fc9fa937b11eaa1b71c4d701ab86e --force',
15
+ ];
16
+ static flags = {
17
+ ...EcdnZoneCommand.baseFlags,
18
+ 'rule-id': Flags.string({
19
+ description: t('flags.ruleId.description', 'Rate limiting rule ID to delete'),
20
+ required: true,
21
+ }),
22
+ force: Flags.boolean({
23
+ char: 'f',
24
+ description: t('flags.force.description', 'Skip confirmation prompt'),
25
+ default: false,
26
+ }),
27
+ };
28
+ async run() {
29
+ this.assertDestructiveOperationAllowed('delete rate limiting rule');
30
+ this.requireOAuthCredentials();
31
+ const zoneId = await this.resolveZoneId();
32
+ const ruleId = this.flags['rule-id'];
33
+ if (!this.flags.force && !this.jsonEnabled()) {
34
+ this.warn(t('commands.ecdn.rate-limit.delete.warning', 'Deleting a rate limiting rule may impact traffic behavior. Use --force to confirm.'));
35
+ return { deleted: false, ruleId };
36
+ }
37
+ if (!this.jsonEnabled()) {
38
+ this.log(t('commands.ecdn.rate-limit.delete.deleting', 'Deleting rate limiting rule {{id}}...', { id: ruleId }));
39
+ }
40
+ const client = this.getCdnZonesRwClient();
41
+ const organizationId = this.getOrganizationId();
42
+ const { error } = await client.DELETE('/organizations/{organizationId}/zones/{zoneId}/rate-limiting/rules/{ruleId}', {
43
+ params: {
44
+ path: { organizationId, zoneId, ruleId },
45
+ },
46
+ });
47
+ if (error) {
48
+ this.error(t('commands.ecdn.rate-limit.delete.error', 'Failed to delete rate limiting rule: {{message}}', {
49
+ message: formatApiError(error),
50
+ }));
51
+ }
52
+ const output = { deleted: true, ruleId };
53
+ if (this.jsonEnabled()) {
54
+ return output;
55
+ }
56
+ this.log('');
57
+ this.log(t('commands.ecdn.rate-limit.delete.success', 'Rate limiting rule deleted successfully.'));
58
+ return output;
59
+ }
60
+ }
61
+ //# sourceMappingURL=delete.js.map