@contrail/cli 3.6.0-alpha-8-alpha.694fd70 → 3.6.0-alpha.693d785
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +45 -151
- package/dist/api/feature-flags.d.ts +3 -0
- package/dist/api/feature-flags.js +29 -0
- package/dist/api/types.d.ts +0 -35
- package/dist/api/types.js +1 -49
- package/dist/api/users.d.ts +1 -0
- package/dist/api/users.js +10 -1
- package/dist/auth/login.d.ts +4 -0
- package/dist/auth/login.js +167 -93
- package/dist/auth/login.spec.js +305 -0
- package/dist/auth/sso.d.ts +36 -0
- package/dist/auth/sso.js +168 -0
- package/dist/auth/sso.spec.js +138 -0
- package/dist/basecommand.d.ts +1 -3
- package/dist/basecommand.js +2 -2
- package/dist/commands/app/getApiKey.js +2 -2
- package/dist/commands/config/set.js +1 -1
- package/dist/commands/feature-flags/export.d.ts +19 -0
- package/dist/commands/feature-flags/export.js +66 -0
- package/dist/commands/feature-flags/export.spec.js +109 -0
- package/dist/commands/feature-flags/import.d.ts +42 -0
- package/dist/commands/feature-flags/import.js +191 -0
- package/dist/commands/feature-flags/import.spec.js +194 -0
- package/dist/commands/instance/export.d.ts +9 -0
- package/dist/commands/instance/export.js +18 -3
- package/dist/commands/instance/export.spec.js +32 -0
- package/dist/commands/instance/import.d.ts +3 -0
- package/dist/commands/instance/import.js +5 -0
- package/dist/commands/instance/import.spec.js +4 -0
- package/dist/commands/login.d.ts +12 -0
- package/dist/commands/login.js +25 -0
- package/dist/common.d.ts +1 -3
- package/dist/common.js +1 -13
- package/dist/helpers/config/config.d.ts +5 -4
- package/dist/helpers/config/config.js +10 -12
- package/dist/helpers/file-helpers.d.ts +0 -1
- package/dist/helpers/file-helpers.js +1 -18
- package/dist/logger.js +1 -4
- package/node_modules/@contrail/entity-compare/package.json +3 -6
- package/node_modules/@contrail/loader/lib/common/conditional-columns.js +1 -1
- package/node_modules/@contrail/loader/lib/constants.d.ts +8 -0
- package/node_modules/@contrail/loader/lib/constants.js +9 -1
- package/node_modules/@contrail/loader/lib/entities-v2/linesheet-v2/item-processor.d.ts +4 -0
- package/node_modules/@contrail/loader/lib/entities-v2/linesheet-v2/item-processor.js +57 -0
- package/node_modules/@contrail/loader/lib/entities-v2/linesheet-v2/item-processor.spec.js +492 -34
- package/node_modules/@contrail/loader/lib/pipeline/validate.js +2 -52
- package/node_modules/@contrail/loader/lib/pipeline/validate.spec.js +0 -85
- package/node_modules/@contrail/loader/package.json +2 -2
- package/node_modules/@contrail/sdk/.github/workflows/publish-to-npm.yml +4 -1
- package/node_modules/@contrail/sdk/lib/auth/login.js +1 -1
- package/node_modules/@contrail/sdk/lib/config/config.d.ts +0 -3
- package/node_modules/@contrail/sdk/lib/config/config.js +7 -13
- package/node_modules/@contrail/sdk/lib/core/request.js +2 -6
- package/node_modules/@contrail/sdk/lib/entities/entities.client.d.ts +0 -2
- package/node_modules/@contrail/sdk/lib/entities/entities.client.js +1 -3
- package/node_modules/@contrail/sdk/lib/entities/entity.resource.registry.js +0 -1
- package/node_modules/@contrail/sdk/package.json +1 -1
- package/oclif.manifest.json +75 -365
- package/package.json +15 -5
- package/dist/commands/entities/create.d.ts +0 -48
- package/dist/commands/entities/create.js +0 -639
- package/dist/commands/entities/create.spec.js +0 -541
- package/dist/commands/entities/delete.d.ts +0 -19
- package/dist/commands/entities/delete.js +0 -134
- package/dist/commands/entities/get.d.ts +0 -24
- package/dist/commands/entities/get.js +0 -273
- package/dist/commands/entities/grammar.spec.js +0 -80
- package/dist/commands/entities/output.spec.js +0 -72
- package/dist/commands/entities/update.d.ts +0 -31
- package/dist/commands/entities/update.js +0 -157
- package/dist/helpers/entities/assortment-items.d.ts +0 -10
- package/dist/helpers/entities/assortment-items.js +0 -84
- package/dist/helpers/entities/batchFetch.d.ts +0 -8
- package/dist/helpers/entities/batchFetch.js +0 -49
- package/dist/helpers/entities/index.d.ts +0 -3
- package/dist/helpers/entities/index.js +0 -6
- package/dist/helpers/entities/items.d.ts +0 -10
- package/dist/helpers/entities/items.js +0 -102
- package/dist/helpers/entities/project-items.d.ts +0 -3
- package/dist/helpers/entities/project-items.js +0 -65
- package/dist/helpers/propertySpecifications/dateRanges.d.ts +0 -38
- package/dist/helpers/propertySpecifications/dateRanges.js +0 -89
- package/dist/helpers/propertySpecifications/dateRanges.spec.js +0 -95
- package/dist/helpers/propertySpecifications/propertySpecifications.d.ts +0 -40
- package/dist/helpers/propertySpecifications/propertySpecifications.js +0 -109
- package/dist/helpers/propertySpecifications/propertySpecifications.spec.d.ts +0 -1
- package/dist/helpers/propertySpecifications/propertySpecifications.spec.js +0 -373
- package/dist/logger.spec.d.ts +0 -1
- package/dist/logger.spec.js +0 -12
- package/node_modules/@contrail/org-config-migration/node_modules/@contrail/sdk/.github/pull_request_template.md +0 -31
- package/node_modules/@contrail/org-config-migration/node_modules/@contrail/sdk/.github/workflows/check-code-formatting.yml +0 -34
- package/node_modules/@contrail/org-config-migration/node_modules/@contrail/sdk/.github/workflows/empty.yml +0 -10
- package/node_modules/@contrail/org-config-migration/node_modules/@contrail/sdk/.github/workflows/generate-sdk-docs.yml +0 -32
- package/node_modules/@contrail/org-config-migration/node_modules/@contrail/sdk/.github/workflows/publish-to-npm.yml +0 -117
- package/node_modules/@contrail/org-config-migration/node_modules/@contrail/sdk/.github/workflows/sdk-lib.yml +0 -27
- package/node_modules/@contrail/org-config-migration/node_modules/@contrail/sdk/.prettierrc.yaml +0 -2
- package/node_modules/@contrail/org-config-migration/node_modules/@contrail/sdk/README.md +0 -72
- package/node_modules/@contrail/org-config-migration/node_modules/@contrail/sdk/home-hero.svg +0 -11
- package/node_modules/@contrail/org-config-migration/node_modules/@contrail/sdk/lib/assets/assets.d.ts +0 -9
- package/node_modules/@contrail/org-config-migration/node_modules/@contrail/sdk/lib/assets/assets.js +0 -54
- package/node_modules/@contrail/org-config-migration/node_modules/@contrail/sdk/lib/assets/index.d.ts +0 -1
- package/node_modules/@contrail/org-config-migration/node_modules/@contrail/sdk/lib/assets/index.js +0 -17
- package/node_modules/@contrail/org-config-migration/node_modules/@contrail/sdk/lib/auth/auth.d.ts +0 -10
- package/node_modules/@contrail/org-config-migration/node_modules/@contrail/sdk/lib/auth/auth.js +0 -6
- package/node_modules/@contrail/org-config-migration/node_modules/@contrail/sdk/lib/auth/index.d.ts +0 -2
- package/node_modules/@contrail/org-config-migration/node_modules/@contrail/sdk/lib/auth/index.js +0 -18
- package/node_modules/@contrail/org-config-migration/node_modules/@contrail/sdk/lib/auth/login.d.ts +0 -10
- package/node_modules/@contrail/org-config-migration/node_modules/@contrail/sdk/lib/auth/login.js +0 -209
- package/node_modules/@contrail/org-config-migration/node_modules/@contrail/sdk/lib/config/config.d.ts +0 -48
- package/node_modules/@contrail/org-config-migration/node_modules/@contrail/sdk/lib/config/config.js +0 -42
- package/node_modules/@contrail/org-config-migration/node_modules/@contrail/sdk/lib/config/index.d.ts +0 -1
- package/node_modules/@contrail/org-config-migration/node_modules/@contrail/sdk/lib/config/index.js +0 -17
- package/node_modules/@contrail/org-config-migration/node_modules/@contrail/sdk/lib/content/content.d.ts +0 -12
- package/node_modules/@contrail/org-config-migration/node_modules/@contrail/sdk/lib/content/content.js +0 -70
- package/node_modules/@contrail/org-config-migration/node_modules/@contrail/sdk/lib/content/index.d.ts +0 -1
- package/node_modules/@contrail/org-config-migration/node_modules/@contrail/sdk/lib/content/index.js +0 -17
- package/node_modules/@contrail/org-config-migration/node_modules/@contrail/sdk/lib/core/index.d.ts +0 -1
- package/node_modules/@contrail/org-config-migration/node_modules/@contrail/sdk/lib/core/index.js +0 -17
- package/node_modules/@contrail/org-config-migration/node_modules/@contrail/sdk/lib/core/request.d.ts +0 -15
- package/node_modules/@contrail/org-config-migration/node_modules/@contrail/sdk/lib/core/request.js +0 -241
- package/node_modules/@contrail/org-config-migration/node_modules/@contrail/sdk/lib/entities/entities.client.d.ts +0 -101
- package/node_modules/@contrail/org-config-migration/node_modules/@contrail/sdk/lib/entities/entities.client.js +0 -306
- package/node_modules/@contrail/org-config-migration/node_modules/@contrail/sdk/lib/entities/entity-reference-expander.d.ts +0 -9
- package/node_modules/@contrail/org-config-migration/node_modules/@contrail/sdk/lib/entities/entity-reference-expander.js +0 -86
- package/node_modules/@contrail/org-config-migration/node_modules/@contrail/sdk/lib/entities/entity-reference.d.ts +0 -6
- package/node_modules/@contrail/org-config-migration/node_modules/@contrail/sdk/lib/entities/entity-reference.js +0 -19
- package/node_modules/@contrail/org-config-migration/node_modules/@contrail/sdk/lib/entities/entity.resource.registry.d.ts +0 -5
- package/node_modules/@contrail/org-config-migration/node_modules/@contrail/sdk/lib/entities/entity.resource.registry.js +0 -59
- package/node_modules/@contrail/org-config-migration/node_modules/@contrail/sdk/lib/entities/index.d.ts +0 -3
- package/node_modules/@contrail/org-config-migration/node_modules/@contrail/sdk/lib/entities/index.js +0 -19
- package/node_modules/@contrail/org-config-migration/node_modules/@contrail/sdk/lib/files/file-type-helper.d.ts +0 -3
- package/node_modules/@contrail/org-config-migration/node_modules/@contrail/sdk/lib/files/file-type-helper.js +0 -24
- package/node_modules/@contrail/org-config-migration/node_modules/@contrail/sdk/lib/files/files.d.ts +0 -19
- package/node_modules/@contrail/org-config-migration/node_modules/@contrail/sdk/lib/files/files.js +0 -151
- package/node_modules/@contrail/org-config-migration/node_modules/@contrail/sdk/lib/files/index.d.ts +0 -1
- package/node_modules/@contrail/org-config-migration/node_modules/@contrail/sdk/lib/files/index.js +0 -17
- package/node_modules/@contrail/org-config-migration/node_modules/@contrail/sdk/lib/index.d.ts +0 -10
- package/node_modules/@contrail/org-config-migration/node_modules/@contrail/sdk/lib/index.js +0 -26
- package/node_modules/@contrail/org-config-migration/node_modules/@contrail/sdk/lib/notifications/index.d.ts +0 -1
- package/node_modules/@contrail/org-config-migration/node_modules/@contrail/sdk/lib/notifications/index.js +0 -17
- package/node_modules/@contrail/org-config-migration/node_modules/@contrail/sdk/lib/notifications/notifications-dispatcher.d.ts +0 -16
- package/node_modules/@contrail/org-config-migration/node_modules/@contrail/sdk/lib/notifications/notifications-dispatcher.js +0 -37
- package/node_modules/@contrail/org-config-migration/node_modules/@contrail/sdk/lib/policies/index.d.ts +0 -1
- package/node_modules/@contrail/org-config-migration/node_modules/@contrail/sdk/lib/policies/index.js +0 -17
- package/node_modules/@contrail/org-config-migration/node_modules/@contrail/sdk/lib/policies/policies-cache.d.ts +0 -12
- package/node_modules/@contrail/org-config-migration/node_modules/@contrail/sdk/lib/policies/policies-cache.js +0 -55
- package/node_modules/@contrail/org-config-migration/node_modules/@contrail/sdk/lib/policies/policies.client.d.ts +0 -9
- package/node_modules/@contrail/org-config-migration/node_modules/@contrail/sdk/lib/policies/policies.client.js +0 -74
- package/node_modules/@contrail/org-config-migration/node_modules/@contrail/sdk/lib/types/index.d.ts +0 -2
- package/node_modules/@contrail/org-config-migration/node_modules/@contrail/sdk/lib/types/index.js +0 -18
- package/node_modules/@contrail/org-config-migration/node_modules/@contrail/sdk/lib/types/sub-types-helper.d.ts +0 -18
- package/node_modules/@contrail/org-config-migration/node_modules/@contrail/sdk/lib/types/sub-types-helper.js +0 -98
- package/node_modules/@contrail/org-config-migration/node_modules/@contrail/sdk/lib/types/types-cache.d.ts +0 -19
- package/node_modules/@contrail/org-config-migration/node_modules/@contrail/sdk/lib/types/types-cache.js +0 -73
- package/node_modules/@contrail/org-config-migration/node_modules/@contrail/sdk/lib/types/types.client.d.ts +0 -42
- package/node_modules/@contrail/org-config-migration/node_modules/@contrail/sdk/lib/types/types.client.js +0 -217
- package/node_modules/@contrail/org-config-migration/node_modules/@contrail/sdk/package.json +0 -64
- package/node_modules/@contrail/org-config-migration/node_modules/@contrail/sdk/scripts/replicate-bug.js +0 -69
- package/node_modules/@contrail/sdk/scripts/replicate-bug.js +0 -69
- /package/dist/{commands/entities/create.spec.d.ts → auth/sso.spec.d.ts} +0 -0
- /package/dist/commands/{entities/grammar.spec.d.ts → feature-flags/export.spec.d.ts} +0 -0
- /package/dist/commands/{entities/output.spec.d.ts → feature-flags/import.spec.d.ts} +0 -0
- /package/dist/{helpers/propertySpecifications/dateRanges.spec.d.ts → commands/instance/export.spec.d.ts} +0 -0
|
@@ -1,95 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
const dateRanges_1 = require("./dateRanges");
|
|
4
|
-
describe('Date Range Specifications', () => {
|
|
5
|
-
describe('isDateRangeSpecification', () => {
|
|
6
|
-
it('should identify valid date range specifications', () => {
|
|
7
|
-
expect((0, dateRanges_1.isDateRangeSpecification)('createdOn=2025-09-15..2025-09-16')).toBe(true);
|
|
8
|
-
expect((0, dateRanges_1.isDateRangeSpecification)('updatedAt=2025-09-15T04:00:00Z..2025-09-16T03:59:59Z')).toBe(true);
|
|
9
|
-
expect((0, dateRanges_1.isDateRangeSpecification)('date=2025-09-15..')).toBe(true);
|
|
10
|
-
expect((0, dateRanges_1.isDateRangeSpecification)('date=..2025-09-16')).toBe(true);
|
|
11
|
-
});
|
|
12
|
-
it('should reject non-date-range specifications', () => {
|
|
13
|
-
expect((0, dateRanges_1.isDateRangeSpecification)('id=123')).toBe(false);
|
|
14
|
-
expect((0, dateRanges_1.isDateRangeSpecification)('name=test')).toBe(false);
|
|
15
|
-
expect((0, dateRanges_1.isDateRangeSpecification)('invalid')).toBe(false);
|
|
16
|
-
expect((0, dateRanges_1.isDateRangeSpecification)('field=value')).toBe(false);
|
|
17
|
-
});
|
|
18
|
-
});
|
|
19
|
-
describe('parseDate', () => {
|
|
20
|
-
it('should parse ISO timestamps correctly', () => {
|
|
21
|
-
const date = (0, dateRanges_1.parseDate)('2025-09-15T04:00:00Z');
|
|
22
|
-
expect(date.toISOString()).toBe('2025-09-15T04:00:00.000Z');
|
|
23
|
-
});
|
|
24
|
-
it('should parse date-only strings as start of day', () => {
|
|
25
|
-
const date = (0, dateRanges_1.parseDate)('2025-09-15', 'start');
|
|
26
|
-
expect(date.toISOString()).toBe('2025-09-15T00:00:00.000Z');
|
|
27
|
-
});
|
|
28
|
-
it('should parse date-only strings as end of day for end bound', () => {
|
|
29
|
-
const date = (0, dateRanges_1.parseDate)('2025-09-15', 'end');
|
|
30
|
-
expect(date.toISOString()).toBe('2025-09-15T23:59:59.999Z');
|
|
31
|
-
});
|
|
32
|
-
it('should throw for invalid date strings', () => {
|
|
33
|
-
expect(() => (0, dateRanges_1.parseDate)('invalid-date')).toThrow('Invalid date format');
|
|
34
|
-
expect(() => (0, dateRanges_1.parseDate)('2025-13-50')).toThrow('Invalid date format');
|
|
35
|
-
});
|
|
36
|
-
});
|
|
37
|
-
describe('parseDateRangeSpecification', () => {
|
|
38
|
-
it('should parse full date ranges', () => {
|
|
39
|
-
const result = (0, dateRanges_1.parseDateRangeSpecification)('createdOn=2025-09-15..2025-09-16');
|
|
40
|
-
expect(result.slug).toBe('createdOn');
|
|
41
|
-
expect(result.range.start).toEqual(new Date('2025-09-15T00:00:00.000Z'));
|
|
42
|
-
expect(result.range.end).toEqual(new Date('2025-09-16T23:59:59.999Z'));
|
|
43
|
-
});
|
|
44
|
-
it('should parse open-ended start ranges', () => {
|
|
45
|
-
const result = (0, dateRanges_1.parseDateRangeSpecification)('createdOn=2025-09-15..');
|
|
46
|
-
expect(result.slug).toBe('createdOn');
|
|
47
|
-
expect(result.range.start).toEqual(new Date('2025-09-15T00:00:00.000Z'));
|
|
48
|
-
expect(result.range.end).toBeUndefined();
|
|
49
|
-
});
|
|
50
|
-
it('should parse open-ended end ranges', () => {
|
|
51
|
-
const result = (0, dateRanges_1.parseDateRangeSpecification)('createdOn=..2025-09-16');
|
|
52
|
-
expect(result.slug).toBe('createdOn');
|
|
53
|
-
expect(result.range.start).toBeUndefined();
|
|
54
|
-
expect(result.range.end).toEqual(new Date('2025-09-16T23:59:59.999Z'));
|
|
55
|
-
});
|
|
56
|
-
it('should parse timestamp ranges', () => {
|
|
57
|
-
const result = (0, dateRanges_1.parseDateRangeSpecification)('createdOn=2025-09-15T04:00:00Z..2025-09-16T03:59:59Z');
|
|
58
|
-
expect(result.slug).toBe('createdOn');
|
|
59
|
-
expect(result.range.start).toEqual(new Date('2025-09-15T04:00:00.000Z'));
|
|
60
|
-
expect(result.range.end).toEqual(new Date('2025-09-16T03:59:59.000Z'));
|
|
61
|
-
});
|
|
62
|
-
it('should throw for invalid specifications', () => {
|
|
63
|
-
expect(() => (0, dateRanges_1.parseDateRangeSpecification)('invalid')).toThrow('Invalid date range specification');
|
|
64
|
-
expect(() => (0, dateRanges_1.parseDateRangeSpecification)('field=..')).toThrow('Date range must have at least one bound');
|
|
65
|
-
expect(() => (0, dateRanges_1.parseDateRangeSpecification)('field=invalid..date')).toThrow('Invalid date format');
|
|
66
|
-
});
|
|
67
|
-
});
|
|
68
|
-
describe('convertDateRangeToJSURL', () => {
|
|
69
|
-
it('should convert full ranges to BETWEEN format', () => {
|
|
70
|
-
const range = {
|
|
71
|
-
start: new Date('2025-09-15T00:00:00.000Z'),
|
|
72
|
-
end: new Date('2025-09-16T23:59:59.999Z'),
|
|
73
|
-
};
|
|
74
|
-
const result = (0, dateRanges_1.convertDateRangeToJSURL)(range);
|
|
75
|
-
expect(result).toBe('BETWEEN 2025-09-15T00:00:00.000Z and 2025-09-16T23:59:59.999Z');
|
|
76
|
-
});
|
|
77
|
-
it('should convert start-only ranges to >= format', () => {
|
|
78
|
-
const range = {
|
|
79
|
-
start: new Date('2025-09-15T00:00:00.000Z'),
|
|
80
|
-
};
|
|
81
|
-
const result = (0, dateRanges_1.convertDateRangeToJSURL)(range);
|
|
82
|
-
expect(result).toBe('>= 2025-09-15T00:00:00.000Z');
|
|
83
|
-
});
|
|
84
|
-
it('should convert end-only ranges to <= format', () => {
|
|
85
|
-
const range = {
|
|
86
|
-
end: new Date('2025-09-16T23:59:59.999Z'),
|
|
87
|
-
};
|
|
88
|
-
const result = (0, dateRanges_1.convertDateRangeToJSURL)(range);
|
|
89
|
-
expect(result).toBe('<= 2025-09-16T23:59:59.999Z');
|
|
90
|
-
});
|
|
91
|
-
it('should throw for empty ranges', () => {
|
|
92
|
-
expect(() => (0, dateRanges_1.convertDateRangeToJSURL)({})).toThrow('Date range must have at least one bound');
|
|
93
|
-
});
|
|
94
|
-
});
|
|
95
|
-
});
|
|
@@ -1,40 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Property Specification
|
|
3
|
-
*
|
|
4
|
-
* Property Specifications is an argument pattern used to express that
|
|
5
|
-
* a specific property has a specific value. In GET requests, this is used
|
|
6
|
-
* to specify the query parameters. In PUT requests, this is used to
|
|
7
|
-
* specify the properties to update.
|
|
8
|
-
*
|
|
9
|
-
* Each follows the format: slug=value
|
|
10
|
-
*
|
|
11
|
-
* It is typically used as the argv in a command.
|
|
12
|
-
*
|
|
13
|
-
* Special handling for empty values:
|
|
14
|
-
* - slug= (empty value) → property is set to undefined (unset)
|
|
15
|
-
* - slug='""' or slug="''" → property is set to empty string ""
|
|
16
|
-
*
|
|
17
|
-
* Examples:
|
|
18
|
-
*
|
|
19
|
-
* contrail entities get color -- id=123
|
|
20
|
-
* contrail entities update color 123 -- name=obsidian hex=000000
|
|
21
|
-
* contrail entities update color 123 -- description= notes='""'
|
|
22
|
-
* contrail entities get loader-processes -- createdOn=2025-09-15..2025-09-16
|
|
23
|
-
*/
|
|
24
|
-
export type PropertySpecification = {
|
|
25
|
-
slug: string;
|
|
26
|
-
value: string | undefined;
|
|
27
|
-
};
|
|
28
|
-
export type PropertySpecificationBySlug = Map<string, string | number | string[] | number[] | undefined>;
|
|
29
|
-
export type PropertySpecificationString = `${string}=${string}`;
|
|
30
|
-
export declare function parsePropertySpecification(spec: PropertySpecificationString): PropertySpecification;
|
|
31
|
-
export declare function parsePropertySpecificationsIntoMap(propertySpecifications: PropertySpecificationString[]): PropertySpecificationBySlug;
|
|
32
|
-
/**
|
|
33
|
-
* Splits command argv tokens (after the typePath) into positional ids and
|
|
34
|
-
* property specifications.
|
|
35
|
-
*/
|
|
36
|
-
export declare function partitionIdsAndSpecs(tokens: string[]): {
|
|
37
|
-
ids: string[];
|
|
38
|
-
specs: PropertySpecificationString[];
|
|
39
|
-
};
|
|
40
|
-
export declare function isValidPropertySpecification(maybeSpec: string): maybeSpec is PropertySpecificationString;
|
|
@@ -1,109 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
/**
|
|
3
|
-
* Property Specification
|
|
4
|
-
*
|
|
5
|
-
* Property Specifications is an argument pattern used to express that
|
|
6
|
-
* a specific property has a specific value. In GET requests, this is used
|
|
7
|
-
* to specify the query parameters. In PUT requests, this is used to
|
|
8
|
-
* specify the properties to update.
|
|
9
|
-
*
|
|
10
|
-
* Each follows the format: slug=value
|
|
11
|
-
*
|
|
12
|
-
* It is typically used as the argv in a command.
|
|
13
|
-
*
|
|
14
|
-
* Special handling for empty values:
|
|
15
|
-
* - slug= (empty value) → property is set to undefined (unset)
|
|
16
|
-
* - slug='""' or slug="''" → property is set to empty string ""
|
|
17
|
-
*
|
|
18
|
-
* Examples:
|
|
19
|
-
*
|
|
20
|
-
* contrail entities get color -- id=123
|
|
21
|
-
* contrail entities update color 123 -- name=obsidian hex=000000
|
|
22
|
-
* contrail entities update color 123 -- description= notes='""'
|
|
23
|
-
* contrail entities get loader-processes -- createdOn=2025-09-15..2025-09-16
|
|
24
|
-
*/
|
|
25
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
26
|
-
exports.isValidPropertySpecification = exports.partitionIdsAndSpecs = exports.parsePropertySpecificationsIntoMap = exports.parsePropertySpecification = void 0;
|
|
27
|
-
const dateRanges_1 = require("./dateRanges");
|
|
28
|
-
// Special tokens for empty strings
|
|
29
|
-
const DOUBLE_QUOTED_EMPTY = '""';
|
|
30
|
-
const SINGLE_QUOTED_EMPTY = "''"; // eslint-disable-line quotes
|
|
31
|
-
function parsePropertySpecification(spec) {
|
|
32
|
-
const equalsIndex = spec.indexOf('=');
|
|
33
|
-
if (equalsIndex === -1) {
|
|
34
|
-
throw new Error(`Invalid property specification: ${spec}`);
|
|
35
|
-
}
|
|
36
|
-
const slug = spec.substring(0, equalsIndex);
|
|
37
|
-
const value = spec.substring(equalsIndex + 1);
|
|
38
|
-
if (!slug) {
|
|
39
|
-
throw new Error(`Invalid property specification: ${spec}`);
|
|
40
|
-
}
|
|
41
|
-
// Handle special cases for empty strings:
|
|
42
|
-
// - x= means undefined (unset the property)
|
|
43
|
-
// - x='""' or x="''" means empty string ""
|
|
44
|
-
let finalValue;
|
|
45
|
-
if (value === '') {
|
|
46
|
-
finalValue = undefined;
|
|
47
|
-
}
|
|
48
|
-
else if (value === DOUBLE_QUOTED_EMPTY || value === SINGLE_QUOTED_EMPTY) {
|
|
49
|
-
finalValue = '';
|
|
50
|
-
}
|
|
51
|
-
else {
|
|
52
|
-
finalValue = value;
|
|
53
|
-
}
|
|
54
|
-
return { slug, value: finalValue };
|
|
55
|
-
}
|
|
56
|
-
exports.parsePropertySpecification = parsePropertySpecification;
|
|
57
|
-
function parsePropertySpecificationsIntoMap(propertySpecifications) {
|
|
58
|
-
const propertySpecBySlug = new Map();
|
|
59
|
-
for (const spec of propertySpecifications) {
|
|
60
|
-
if ((0, dateRanges_1.isDateRangeSpecification)(spec)) {
|
|
61
|
-
const { slug, range } = (0, dateRanges_1.parseDateRangeSpecification)(spec);
|
|
62
|
-
const jsUrlValue = (0, dateRanges_1.convertDateRangeToJSURL)(range);
|
|
63
|
-
propertySpecBySlug.set(slug, jsUrlValue);
|
|
64
|
-
continue;
|
|
65
|
-
}
|
|
66
|
-
const { slug, value } = parsePropertySpecification(spec);
|
|
67
|
-
if (slug === 'ids' && value !== undefined) {
|
|
68
|
-
// ids is the one comma-split exception: it is a list of ids by definition
|
|
69
|
-
// and ids never contain commas.
|
|
70
|
-
const idsArray = value.split(',').map((id) => id.trim());
|
|
71
|
-
const existingIds = propertySpecBySlug.get(slug);
|
|
72
|
-
propertySpecBySlug.set(slug, Array.isArray(existingIds) ? [...existingIds, ...idsArray] : idsArray);
|
|
73
|
-
continue;
|
|
74
|
-
}
|
|
75
|
-
const existing = propertySpecBySlug.get(slug);
|
|
76
|
-
if (propertySpecBySlug.has(slug) && existing !== undefined && value !== undefined) {
|
|
77
|
-
propertySpecBySlug.set(slug, Array.isArray(existing) ? [...existing, value] : [existing, value]);
|
|
78
|
-
continue;
|
|
79
|
-
}
|
|
80
|
-
propertySpecBySlug.set(slug, value);
|
|
81
|
-
}
|
|
82
|
-
return propertySpecBySlug;
|
|
83
|
-
}
|
|
84
|
-
exports.parsePropertySpecificationsIntoMap = parsePropertySpecificationsIntoMap;
|
|
85
|
-
/**
|
|
86
|
-
* Splits command argv tokens (after the typePath) into positional ids and
|
|
87
|
-
* property specifications.
|
|
88
|
-
*/
|
|
89
|
-
function partitionIdsAndSpecs(tokens) {
|
|
90
|
-
return {
|
|
91
|
-
ids: tokens.filter((token) => !token.includes('=')),
|
|
92
|
-
specs: tokens.filter(isValidPropertySpecification),
|
|
93
|
-
};
|
|
94
|
-
}
|
|
95
|
-
exports.partitionIdsAndSpecs = partitionIdsAndSpecs;
|
|
96
|
-
function isValidPropertySpecification(maybeSpec) {
|
|
97
|
-
try {
|
|
98
|
-
if ((0, dateRanges_1.isDateRangeSpecification)(maybeSpec)) {
|
|
99
|
-
(0, dateRanges_1.parseDateRangeSpecification)(maybeSpec);
|
|
100
|
-
return true;
|
|
101
|
-
}
|
|
102
|
-
const { slug } = parsePropertySpecification(maybeSpec);
|
|
103
|
-
return !!slug;
|
|
104
|
-
}
|
|
105
|
-
catch (e) {
|
|
106
|
-
return false;
|
|
107
|
-
}
|
|
108
|
-
}
|
|
109
|
-
exports.isValidPropertySpecification = isValidPropertySpecification;
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export {};
|
|
@@ -1,373 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
const propertySpecifications_1 = require("./propertySpecifications");
|
|
4
|
-
describe('parsePropertySpecification', () => {
|
|
5
|
-
it('should parse a valid property specification', () => {
|
|
6
|
-
const spec = 'name=john';
|
|
7
|
-
const result = (0, propertySpecifications_1.parsePropertySpecification)(spec);
|
|
8
|
-
expect(result).toEqual({
|
|
9
|
-
slug: 'name',
|
|
10
|
-
value: 'john',
|
|
11
|
-
});
|
|
12
|
-
});
|
|
13
|
-
it('should parse property specification with numeric value', () => {
|
|
14
|
-
const spec = 'id=123';
|
|
15
|
-
const result = (0, propertySpecifications_1.parsePropertySpecification)(spec);
|
|
16
|
-
expect(result).toEqual({
|
|
17
|
-
slug: 'id',
|
|
18
|
-
value: '123',
|
|
19
|
-
});
|
|
20
|
-
});
|
|
21
|
-
it('should parse property specification with hex color value', () => {
|
|
22
|
-
const spec = 'hex=000000';
|
|
23
|
-
const result = (0, propertySpecifications_1.parsePropertySpecification)(spec);
|
|
24
|
-
expect(result).toEqual({
|
|
25
|
-
slug: 'hex',
|
|
26
|
-
value: '000000',
|
|
27
|
-
});
|
|
28
|
-
});
|
|
29
|
-
it('should parse property specification with spaces in value', () => {
|
|
30
|
-
const spec = 'name=john doe';
|
|
31
|
-
const result = (0, propertySpecifications_1.parsePropertySpecification)(spec);
|
|
32
|
-
expect(result).toEqual({
|
|
33
|
-
slug: 'name',
|
|
34
|
-
value: 'john doe',
|
|
35
|
-
});
|
|
36
|
-
});
|
|
37
|
-
it('should parse property specification with equals sign in value', () => {
|
|
38
|
-
const spec = 'formula=x=y+z';
|
|
39
|
-
const result = (0, propertySpecifications_1.parsePropertySpecification)(spec);
|
|
40
|
-
expect(result).toEqual({
|
|
41
|
-
slug: 'formula',
|
|
42
|
-
value: 'x=y+z',
|
|
43
|
-
});
|
|
44
|
-
});
|
|
45
|
-
it('should parse property specification with empty value', () => {
|
|
46
|
-
const spec = 'description=';
|
|
47
|
-
const result = (0, propertySpecifications_1.parsePropertySpecification)(spec);
|
|
48
|
-
expect(result).toEqual({
|
|
49
|
-
slug: 'description',
|
|
50
|
-
value: undefined,
|
|
51
|
-
});
|
|
52
|
-
});
|
|
53
|
-
it('should distinguish between empty value and empty string', () => {
|
|
54
|
-
const emptySpec = 'description=';
|
|
55
|
-
const emptyStringSpec = 'description=""';
|
|
56
|
-
const emptyResult = (0, propertySpecifications_1.parsePropertySpecification)(emptySpec);
|
|
57
|
-
const emptyStringResult = (0, propertySpecifications_1.parsePropertySpecification)(emptyStringSpec);
|
|
58
|
-
expect(emptyResult).toEqual({
|
|
59
|
-
slug: 'description',
|
|
60
|
-
value: undefined,
|
|
61
|
-
});
|
|
62
|
-
expect(emptyStringResult).toEqual({
|
|
63
|
-
slug: 'description',
|
|
64
|
-
value: '',
|
|
65
|
-
});
|
|
66
|
-
});
|
|
67
|
-
it('should handle both double and single quoted empty strings', () => {
|
|
68
|
-
const doubleQuotedSpec = 'field=""';
|
|
69
|
-
const singleQuotedSpec = "field=''"; // eslint-disable-line quotes
|
|
70
|
-
const doubleQuotedResult = (0, propertySpecifications_1.parsePropertySpecification)(doubleQuotedSpec);
|
|
71
|
-
const singleQuotedResult = (0, propertySpecifications_1.parsePropertySpecification)(singleQuotedSpec);
|
|
72
|
-
expect(doubleQuotedResult).toEqual({
|
|
73
|
-
slug: 'field',
|
|
74
|
-
value: '',
|
|
75
|
-
});
|
|
76
|
-
expect(singleQuotedResult).toEqual({
|
|
77
|
-
slug: 'field',
|
|
78
|
-
value: '',
|
|
79
|
-
});
|
|
80
|
-
});
|
|
81
|
-
it('should throw error for spec without equals sign', () => {
|
|
82
|
-
const spec = 'invalidspec';
|
|
83
|
-
expect(() => (0, propertySpecifications_1.parsePropertySpecification)(spec)).toThrow('Invalid property specification: invalidspec');
|
|
84
|
-
});
|
|
85
|
-
it('should throw error for spec with only equals sign', () => {
|
|
86
|
-
const spec = '=';
|
|
87
|
-
expect(() => (0, propertySpecifications_1.parsePropertySpecification)(spec)).toThrow('Invalid property specification: =');
|
|
88
|
-
});
|
|
89
|
-
it('should throw error for spec with empty slug', () => {
|
|
90
|
-
const spec = '=value';
|
|
91
|
-
expect(() => (0, propertySpecifications_1.parsePropertySpecification)(spec)).toThrow('Invalid property specification: =value');
|
|
92
|
-
});
|
|
93
|
-
it('should parse property specification with special characters in slug', () => {
|
|
94
|
-
const spec = 'property_name=value';
|
|
95
|
-
const result = (0, propertySpecifications_1.parsePropertySpecification)(spec);
|
|
96
|
-
expect(result).toEqual({
|
|
97
|
-
slug: 'property_name',
|
|
98
|
-
value: 'value',
|
|
99
|
-
});
|
|
100
|
-
});
|
|
101
|
-
it('should parse property specification with hyphenated slug', () => {
|
|
102
|
-
const spec = 'property-name=value';
|
|
103
|
-
const result = (0, propertySpecifications_1.parsePropertySpecification)(spec);
|
|
104
|
-
expect(result).toEqual({
|
|
105
|
-
slug: 'property-name',
|
|
106
|
-
value: 'value',
|
|
107
|
-
});
|
|
108
|
-
});
|
|
109
|
-
});
|
|
110
|
-
describe('parsePropertySpecificationsIntoMap', () => {
|
|
111
|
-
it('should parse multiple property specifications into a map', () => {
|
|
112
|
-
const specs = ['name=obsidian', 'hex=000000', 'id=123'];
|
|
113
|
-
const result = (0, propertySpecifications_1.parsePropertySpecificationsIntoMap)(specs);
|
|
114
|
-
expect(result).toBeInstanceOf(Map);
|
|
115
|
-
expect(result.get('name')).toBe('obsidian');
|
|
116
|
-
expect(result.get('hex')).toBe('000000');
|
|
117
|
-
expect(result.get('id')).toBe('123');
|
|
118
|
-
expect(result.size).toBe(3);
|
|
119
|
-
});
|
|
120
|
-
it('should handle empty array', () => {
|
|
121
|
-
const specs = [];
|
|
122
|
-
const result = (0, propertySpecifications_1.parsePropertySpecificationsIntoMap)(specs);
|
|
123
|
-
expect(result).toBeInstanceOf(Map);
|
|
124
|
-
expect(result.size).toBe(0);
|
|
125
|
-
});
|
|
126
|
-
it('should handle single property specification', () => {
|
|
127
|
-
const specs = ['name=john'];
|
|
128
|
-
const result = (0, propertySpecifications_1.parsePropertySpecificationsIntoMap)(specs);
|
|
129
|
-
expect(result).toBeInstanceOf(Map);
|
|
130
|
-
expect(result.get('name')).toBe('john');
|
|
131
|
-
expect(result.size).toBe(1);
|
|
132
|
-
});
|
|
133
|
-
it('should handle property specifications with complex values', () => {
|
|
134
|
-
const specs = [
|
|
135
|
-
'description=This is a long description with spaces',
|
|
136
|
-
'formula=x=y+z',
|
|
137
|
-
'url=https://example.com',
|
|
138
|
-
];
|
|
139
|
-
const result = (0, propertySpecifications_1.parsePropertySpecificationsIntoMap)(specs);
|
|
140
|
-
expect(result.get('description')).toBe('This is a long description with spaces');
|
|
141
|
-
expect(result.get('formula')).toBe('x=y+z'); // Now correctly handles multiple equals
|
|
142
|
-
expect(result.get('url')).toBe('https://example.com');
|
|
143
|
-
expect(result.size).toBe(3);
|
|
144
|
-
});
|
|
145
|
-
it('should accumulate repeated keys into an array', () => {
|
|
146
|
-
const specs = ['name=first', 'name=second', 'name=third'];
|
|
147
|
-
const result = (0, propertySpecifications_1.parsePropertySpecificationsIntoMap)(specs);
|
|
148
|
-
expect(result.get('name')).toEqual(['first', 'second', 'third']);
|
|
149
|
-
expect(result.size).toBe(1);
|
|
150
|
-
});
|
|
151
|
-
it('should keep a single value scalar', () => {
|
|
152
|
-
const specs = ['status=archived'];
|
|
153
|
-
const result = (0, propertySpecifications_1.parsePropertySpecificationsIntoMap)(specs);
|
|
154
|
-
expect(result.get('status')).toBe('archived');
|
|
155
|
-
});
|
|
156
|
-
it('should handle property specifications with empty values', () => {
|
|
157
|
-
const specs = ['name=john', 'description=', 'notes=""'];
|
|
158
|
-
const result = (0, propertySpecifications_1.parsePropertySpecificationsIntoMap)(specs);
|
|
159
|
-
expect(result.get('name')).toBe('john');
|
|
160
|
-
expect(result.get('description')).toBeUndefined();
|
|
161
|
-
expect(result.get('notes')).toBe(''); // Empty quotes are converted to empty string
|
|
162
|
-
expect(result.size).toBe(3);
|
|
163
|
-
});
|
|
164
|
-
it('should throw error for invalid property specifications', () => {
|
|
165
|
-
const specs = [
|
|
166
|
-
'name=john',
|
|
167
|
-
'invalid',
|
|
168
|
-
];
|
|
169
|
-
expect(() => (0, propertySpecifications_1.parsePropertySpecificationsIntoMap)(specs)).toThrow('Invalid property specification: invalid');
|
|
170
|
-
});
|
|
171
|
-
it('should build roles arrays from repeated keys, with commas literal', () => {
|
|
172
|
-
const specs = ['roles=option', 'roles=family', 'name=Test'];
|
|
173
|
-
const result = (0, propertySpecifications_1.parsePropertySpecificationsIntoMap)(specs);
|
|
174
|
-
expect(result.get('roles')).toEqual(['option', 'family']);
|
|
175
|
-
expect(result.get('name')).toBe('Test');
|
|
176
|
-
});
|
|
177
|
-
it('should treat a comma in a roles value as literal', () => {
|
|
178
|
-
const specs = ['roles=option,family'];
|
|
179
|
-
const result = (0, propertySpecifications_1.parsePropertySpecificationsIntoMap)(specs);
|
|
180
|
-
expect(result.get('roles')).toBe('option,family');
|
|
181
|
-
});
|
|
182
|
-
it('should keep commas literal in ordinary values', () => {
|
|
183
|
-
const specs = ['name=my,name'];
|
|
184
|
-
const result = (0, propertySpecifications_1.parsePropertySpecificationsIntoMap)(specs);
|
|
185
|
-
expect(result.get('name')).toBe('my,name');
|
|
186
|
-
});
|
|
187
|
-
it('should handle ids as comma-separated array', () => {
|
|
188
|
-
const specs = ['ids=1,2,3', 'name=Test'];
|
|
189
|
-
const result = (0, propertySpecifications_1.parsePropertySpecificationsIntoMap)(specs);
|
|
190
|
-
expect(result.get('ids')).toEqual(['1', '2', '3']);
|
|
191
|
-
expect(result.get('name')).toBe('Test');
|
|
192
|
-
});
|
|
193
|
-
it('should accumulate repeated ids keys', () => {
|
|
194
|
-
const specs = ['ids=1,2', 'ids=3'];
|
|
195
|
-
const result = (0, propertySpecifications_1.parsePropertySpecificationsIntoMap)(specs);
|
|
196
|
-
expect(result.get('ids')).toEqual(['1', '2', '3']);
|
|
197
|
-
});
|
|
198
|
-
it('should handle ids as single value', () => {
|
|
199
|
-
const specs = ['ids=123'];
|
|
200
|
-
const result = (0, propertySpecifications_1.parsePropertySpecificationsIntoMap)(specs);
|
|
201
|
-
expect(result.get('ids')).toEqual(['123']);
|
|
202
|
-
});
|
|
203
|
-
it('should trim whitespace in ids array', () => {
|
|
204
|
-
const specs = ['ids=1, 2, 3, 4'];
|
|
205
|
-
const result = (0, propertySpecifications_1.parsePropertySpecificationsIntoMap)(specs);
|
|
206
|
-
expect(result.get('ids')).toEqual(['1', '2', '3', '4']);
|
|
207
|
-
});
|
|
208
|
-
it('should not parse roles as array when value is undefined', () => {
|
|
209
|
-
const specs = ['roles='];
|
|
210
|
-
const result = (0, propertySpecifications_1.parsePropertySpecificationsIntoMap)(specs);
|
|
211
|
-
expect(result.get('roles')).toBeUndefined();
|
|
212
|
-
});
|
|
213
|
-
it('should not parse ids as array when value is undefined', () => {
|
|
214
|
-
const specs = ['ids='];
|
|
215
|
-
const result = (0, propertySpecifications_1.parsePropertySpecificationsIntoMap)(specs);
|
|
216
|
-
expect(result.get('ids')).toBeUndefined();
|
|
217
|
-
});
|
|
218
|
-
});
|
|
219
|
-
describe('isValidPropertySpecification', () => {
|
|
220
|
-
it('should return true for valid property specifications', () => {
|
|
221
|
-
expect((0, propertySpecifications_1.isValidPropertySpecification)('name=john')).toBe(true);
|
|
222
|
-
expect((0, propertySpecifications_1.isValidPropertySpecification)('id=123')).toBe(true);
|
|
223
|
-
expect((0, propertySpecifications_1.isValidPropertySpecification)('hex=000000')).toBe(true);
|
|
224
|
-
expect((0, propertySpecifications_1.isValidPropertySpecification)('description=This is a description')).toBe(true);
|
|
225
|
-
expect((0, propertySpecifications_1.isValidPropertySpecification)('formula=x=y+z')).toBe(true);
|
|
226
|
-
expect((0, propertySpecifications_1.isValidPropertySpecification)('property_name=value')).toBe(true);
|
|
227
|
-
expect((0, propertySpecifications_1.isValidPropertySpecification)('property-name=value')).toBe(true);
|
|
228
|
-
});
|
|
229
|
-
it('should return true for property specifications with empty values', () => {
|
|
230
|
-
// Now implementation should accept empty values
|
|
231
|
-
expect((0, propertySpecifications_1.isValidPropertySpecification)('description=')).toBe(true);
|
|
232
|
-
expect((0, propertySpecifications_1.isValidPropertySpecification)('notes=')).toBe(true);
|
|
233
|
-
});
|
|
234
|
-
it('should return false for invalid property specifications', () => {
|
|
235
|
-
expect((0, propertySpecifications_1.isValidPropertySpecification)('invalid')).toBe(false);
|
|
236
|
-
expect((0, propertySpecifications_1.isValidPropertySpecification)('')).toBe(false);
|
|
237
|
-
expect((0, propertySpecifications_1.isValidPropertySpecification)('=')).toBe(false);
|
|
238
|
-
expect((0, propertySpecifications_1.isValidPropertySpecification)('=value')).toBe(false);
|
|
239
|
-
});
|
|
240
|
-
it('should return false for null or undefined', () => {
|
|
241
|
-
expect((0, propertySpecifications_1.isValidPropertySpecification)(null)).toBe(false);
|
|
242
|
-
expect((0, propertySpecifications_1.isValidPropertySpecification)(undefined)).toBe(false);
|
|
243
|
-
});
|
|
244
|
-
it('should return false for non-string values', () => {
|
|
245
|
-
expect((0, propertySpecifications_1.isValidPropertySpecification)(123)).toBe(false);
|
|
246
|
-
expect((0, propertySpecifications_1.isValidPropertySpecification)({})).toBe(false);
|
|
247
|
-
expect((0, propertySpecifications_1.isValidPropertySpecification)([])).toBe(false);
|
|
248
|
-
});
|
|
249
|
-
it('should act as type guard', () => {
|
|
250
|
-
const maybeSpec = 'name=john';
|
|
251
|
-
if ((0, propertySpecifications_1.isValidPropertySpecification)(maybeSpec)) {
|
|
252
|
-
// TypeScript should recognize maybeSpec as PropertySpecificationString
|
|
253
|
-
const parsed = (0, propertySpecifications_1.parsePropertySpecification)(maybeSpec);
|
|
254
|
-
expect(parsed.slug).toBe('name');
|
|
255
|
-
expect(parsed.value).toBe('john');
|
|
256
|
-
}
|
|
257
|
-
});
|
|
258
|
-
});
|
|
259
|
-
describe('integration tests', () => {
|
|
260
|
-
it('should work with the example from the comments', () => {
|
|
261
|
-
// Example: contrail entities get color -- id=123
|
|
262
|
-
const getSpecs = ['id=123'];
|
|
263
|
-
const getMap = (0, propertySpecifications_1.parsePropertySpecificationsIntoMap)(getSpecs);
|
|
264
|
-
expect(getMap.get('id')).toBe('123');
|
|
265
|
-
expect(getMap.size).toBe(1);
|
|
266
|
-
});
|
|
267
|
-
it('should work with the update example from the comments', () => {
|
|
268
|
-
// Example: contrail entities update color 123 -- name=obsidian hex=000000
|
|
269
|
-
const updateSpecs = ['name=obsidian', 'hex=000000'];
|
|
270
|
-
const updateMap = (0, propertySpecifications_1.parsePropertySpecificationsIntoMap)(updateSpecs);
|
|
271
|
-
expect(updateMap.get('name')).toBe('obsidian');
|
|
272
|
-
expect(updateMap.get('hex')).toBe('000000');
|
|
273
|
-
expect(updateMap.size).toBe(2);
|
|
274
|
-
});
|
|
275
|
-
it('should handle validation before parsing', () => {
|
|
276
|
-
const userInputs = ['name=john', 'invalid', 'id=123', '=empty'];
|
|
277
|
-
const validSpecs = userInputs.filter(propertySpecifications_1.isValidPropertySpecification);
|
|
278
|
-
expect(validSpecs).toEqual(['name=john', 'id=123']);
|
|
279
|
-
const map = (0, propertySpecifications_1.parsePropertySpecificationsIntoMap)(validSpecs);
|
|
280
|
-
expect(map.get('name')).toBe('john');
|
|
281
|
-
expect(map.get('id')).toBe('123');
|
|
282
|
-
expect(map.size).toBe(2);
|
|
283
|
-
});
|
|
284
|
-
it('should handle command line parsing issue with empty strings', () => {
|
|
285
|
-
// When user types: contrail entities update color 123 -- description="" notes=''
|
|
286
|
-
// The shell may convert this to: ['description=', 'notes='] or ['description=""', 'notes=\'\'']
|
|
287
|
-
// depending on the shell and escaping
|
|
288
|
-
// Test case 1: Shell strips quotes (common case)
|
|
289
|
-
const shellStrippedSpecs = ['description=', 'notes='];
|
|
290
|
-
const shellStrippedMap = (0, propertySpecifications_1.parsePropertySpecificationsIntoMap)(shellStrippedSpecs);
|
|
291
|
-
expect(shellStrippedMap.get('description')).toBeUndefined(); // Empty = undefined
|
|
292
|
-
expect(shellStrippedMap.get('notes')).toBeUndefined(); // Empty = undefined
|
|
293
|
-
// Test case 2: Shell preserves quotes (desired case for empty strings)
|
|
294
|
-
const quotedSpecs = ['description=""'];
|
|
295
|
-
const quotedMap = (0, propertySpecifications_1.parsePropertySpecificationsIntoMap)(quotedSpecs);
|
|
296
|
-
expect(quotedMap.get('description')).toBe(''); // Quoted empty = empty string
|
|
297
|
-
// Test case 3: Mixed usage
|
|
298
|
-
const mixedSpecs = ['name=test', 'description=', 'notes=""'];
|
|
299
|
-
const mixedMap = (0, propertySpecifications_1.parsePropertySpecificationsIntoMap)(mixedSpecs);
|
|
300
|
-
expect(mixedMap.get('name')).toBe('test');
|
|
301
|
-
expect(mixedMap.get('description')).toBeUndefined(); // Unset
|
|
302
|
-
expect(mixedMap.get('notes')).toBe(''); // Empty string
|
|
303
|
-
expect(mixedMap.size).toBe(3);
|
|
304
|
-
});
|
|
305
|
-
});
|
|
306
|
-
describe('edge cases and limitations', () => {
|
|
307
|
-
it('should handle multiple equals signs correctly', () => {
|
|
308
|
-
// This test shows that multiple equals signs are now handled correctly
|
|
309
|
-
const spec = 'calculation=2+2=4';
|
|
310
|
-
const result = (0, propertySpecifications_1.parsePropertySpecification)(spec);
|
|
311
|
-
expect(result).toEqual({
|
|
312
|
-
slug: 'calculation',
|
|
313
|
-
value: '2+2=4', // now preserves everything after first equals
|
|
314
|
-
});
|
|
315
|
-
});
|
|
316
|
-
it('should handle the specific example equation=x+z=1', () => {
|
|
317
|
-
const spec = 'equation=x+z=1';
|
|
318
|
-
const result = (0, propertySpecifications_1.parsePropertySpecification)(spec);
|
|
319
|
-
expect(result).toEqual({
|
|
320
|
-
slug: 'equation',
|
|
321
|
-
value: 'x+z=1',
|
|
322
|
-
});
|
|
323
|
-
});
|
|
324
|
-
it('should handle mathematical expressions with one equals', () => {
|
|
325
|
-
const spec = 'formula=x+y';
|
|
326
|
-
const result = (0, propertySpecifications_1.parsePropertySpecification)(spec);
|
|
327
|
-
expect(result).toEqual({
|
|
328
|
-
slug: 'formula',
|
|
329
|
-
value: 'x+y',
|
|
330
|
-
});
|
|
331
|
-
});
|
|
332
|
-
it('should handle URLs without equals signs', () => {
|
|
333
|
-
const spec = 'url=https://example.com/path';
|
|
334
|
-
const result = (0, propertySpecifications_1.parsePropertySpecification)(spec);
|
|
335
|
-
expect(result).toEqual({
|
|
336
|
-
slug: 'url',
|
|
337
|
-
value: 'https://example.com/path',
|
|
338
|
-
});
|
|
339
|
-
});
|
|
340
|
-
it('should handle JSON-like values', () => {
|
|
341
|
-
const spec = 'config={"key":"value"}';
|
|
342
|
-
const result = (0, propertySpecifications_1.parsePropertySpecification)(spec);
|
|
343
|
-
expect(result).toEqual({
|
|
344
|
-
slug: 'config',
|
|
345
|
-
value: '{"key":"value"}',
|
|
346
|
-
});
|
|
347
|
-
});
|
|
348
|
-
it('should handle comma-separated values', () => {
|
|
349
|
-
const spec = 'tags=red,blue,green';
|
|
350
|
-
const result = (0, propertySpecifications_1.parsePropertySpecification)(spec);
|
|
351
|
-
expect(result).toEqual({
|
|
352
|
-
slug: 'tags',
|
|
353
|
-
value: 'red,blue,green',
|
|
354
|
-
});
|
|
355
|
-
});
|
|
356
|
-
it('should handle escaped characters', () => {
|
|
357
|
-
const spec = 'message=Hello\\nWorld';
|
|
358
|
-
const result = (0, propertySpecifications_1.parsePropertySpecification)(spec);
|
|
359
|
-
expect(result).toEqual({
|
|
360
|
-
slug: 'message',
|
|
361
|
-
value: 'Hello\\nWorld',
|
|
362
|
-
});
|
|
363
|
-
});
|
|
364
|
-
it('should handle whitespace in slugs', () => {
|
|
365
|
-
// This documents current behavior - spaces in slugs are allowed
|
|
366
|
-
const spec = 'property name=value';
|
|
367
|
-
const result = (0, propertySpecifications_1.parsePropertySpecification)(spec);
|
|
368
|
-
expect(result).toEqual({
|
|
369
|
-
slug: 'property name',
|
|
370
|
-
value: 'value',
|
|
371
|
-
});
|
|
372
|
-
});
|
|
373
|
-
});
|
package/dist/logger.spec.d.ts
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export {};
|
package/dist/logger.spec.js
DELETED
|
@@ -1,12 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
const tslib_1 = require("tslib");
|
|
4
|
-
const logger_1 = tslib_1.__importDefault(require("./logger"));
|
|
5
|
-
describe('logger', () => {
|
|
6
|
-
it('should write every log level to stderr so stdout carries only command output', () => {
|
|
7
|
-
const consoleTransport = logger_1.default.transports[0];
|
|
8
|
-
for (const level of ['error', 'warn', 'info', 'debug']) {
|
|
9
|
-
expect(consoleTransport.stderrLevels[level]).toBe(true);
|
|
10
|
-
}
|
|
11
|
-
});
|
|
12
|
-
});
|
|
@@ -1,31 +0,0 @@
|
|
|
1
|
-
## What
|
|
2
|
-
|
|
3
|
-
- [ ] Bugfix
|
|
4
|
-
- [ ] Feature
|
|
5
|
-
- [ ] Enhancement
|
|
6
|
-
|
|
7
|
-
Description:
|
|
8
|
-
|
|
9
|
-
<!--
|
|
10
|
-
Describe the functional changes of the PR.
|
|
11
|
-
|
|
12
|
-
If the mechanism of your change are complex, describe them in detail as you
|
|
13
|
-
would if you were explaining them to a team mate.
|
|
14
|
-
|
|
15
|
-
If the PR is simple, there is no need to repeat yourself. A small description
|
|
16
|
-
is sufficient.
|
|
17
|
-
-->
|
|
18
|
-
|
|
19
|
-
## Why
|
|
20
|
-
|
|
21
|
-
<!--
|
|
22
|
-
why is this change needed? Same rules as with #What
|
|
23
|
-
-->
|
|
24
|
-
|
|
25
|
-
## Testing added
|
|
26
|
-
|
|
27
|
-
<!--
|
|
28
|
-
Describe the testing you added to this PR
|
|
29
|
-
-->
|
|
30
|
-
|
|
31
|
-
## Link to Jira ticket(s)
|