@platecms/delta-plate-resource-notation 0.13.0 → 1.2.0

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 CHANGED
@@ -14,8 +14,7 @@ We define the Plate Resource Name (PRN, derived from URN) format as follows:
14
14
 
15
15
  - Partition: The instance of Plate Delta in which the resource resides. E.g. `plate`, `plate-dev`, `<client-name>`
16
16
  - Organization ID: The ID of the organization that owns the resource.
17
- - Service: The abbreviation of the name of the service that owns resource. E.g. `am` (Asset Manager), `cxc` (Content
18
- Experience Center), etc.
17
+ - Service: The abbreviation of the name of the service that owns resource. E.g. `ps` (Platform Service), `cms` (Content Management Center), etc.
19
18
  - Resource type: The type of the resource. E.g. asset, directory, content-type
20
19
  - Resource id: Id of the resource. E.g. 1234, abcd. This can be any string.
21
20
 
@@ -23,8 +22,8 @@ Each name is formatted as slug: `asset-library`
23
22
 
24
23
  Some examples are:
25
24
 
26
- - `prn:plate:am:1234:asset:124124`
27
- - `prn:jumbo:cxc:abc:content-value:xyz`
25
+ - `prn:plate:ps:1234:asset:124124`
26
+ - `prn:jumbo:cms:abc:content-value:xyz`
28
27
 
29
28
  # Requests and responses
30
29
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@platecms/delta-plate-resource-notation",
3
- "version": "0.13.0",
3
+ "version": "1.2.0",
4
4
  "description": "PRNs are Plate's replacement for IDs. They contain context about the resource the PRN describes.",
5
5
  "license": "UNLICENSED",
6
6
  "publishConfig": {
@@ -8,7 +8,7 @@ describe("PRN", () => {
8
8
  // Arrange
9
9
  const partition = "aa";
10
10
  const organizationId = "bb";
11
- const service = ServiceAbbreviation.ASSET_MANAGER;
11
+ const service = ServiceAbbreviation.PLATFORM_SERVICE;
12
12
  const resourceType = "dd";
13
13
  const resourceId = "ee";
14
14
 
@@ -28,14 +28,14 @@ describe("PRN", () => {
28
28
  {
29
29
  partition: "aa",
30
30
  organizationId: "bb",
31
- service: ServiceAbbreviation.ASSET_MANAGER,
31
+ service: ServiceAbbreviation.PLATFORM_SERVICE,
32
32
  resourceName: "cc",
33
33
  resourceId: "", // Empty part
34
34
  },
35
35
  {
36
36
  partition: "aa",
37
37
  organizationId: "b:b", // Part has a colon in it
38
- service: ServiceAbbreviation.ASSET_MANAGER,
38
+ service: ServiceAbbreviation.PLATFORM_SERVICE,
39
39
  resourceName: "cc",
40
40
  resourceId: "dd",
41
41
  },
@@ -51,7 +51,7 @@ describe("PRN", () => {
51
51
  {
52
52
  partition: "ab",
53
53
  organizationId: "cd",
54
- service: ServiceAbbreviation.CONTENT_EXPERIENCE_CENTER,
54
+ service: ServiceAbbreviation.CONTENT_MANAGEMENT_SERVICE,
55
55
  resourceType: "ef",
56
56
  resourceId: "gh",
57
57
  },
@@ -66,8 +66,8 @@ describe("PRN", () => {
66
66
 
67
67
  describe("fromString", () => {
68
68
  it("creates a PRN for a given PRN string successfully", async () => {
69
- const result: PRN = PRN.fromString(`prn:aa:bb:${ServiceAbbreviation.ACCESS_CONTROL}:cc:dd`);
70
- expect(result).toStrictEqual(new PRN("aa", "bb", ServiceAbbreviation.ACCESS_CONTROL, "cc", "dd"));
69
+ const result: PRN = PRN.fromString(`prn:aa:bb:${ServiceAbbreviation.PLATFORM_SERVICE}:cc:dd`);
70
+ expect(result).toStrictEqual(new PRN("aa", "bb", ServiceAbbreviation.PLATFORM_SERVICE, "cc", "dd"));
71
71
  });
72
72
 
73
73
  it.each([
@@ -81,22 +81,22 @@ describe("PRN", () => {
81
81
  describe("equals", () => {
82
82
  it("Successfully checks equivalence of two equivalent PRN objects", async () => {
83
83
  expect(
84
- new PRN("ab", "cd", ServiceAbbreviation.ORGANIZATIONS_CENTER, "ef", "gh").equals(
85
- new PRN("ab", "cd", ServiceAbbreviation.ORGANIZATIONS_CENTER, "ef", "gh"),
84
+ new PRN("ab", "cd", ServiceAbbreviation.PLATFORM_SERVICE, "ef", "gh").equals(
85
+ new PRN("ab", "cd", ServiceAbbreviation.PLATFORM_SERVICE, "ef", "gh"),
86
86
  ),
87
87
  ).toStrictEqual(true);
88
88
  });
89
89
 
90
90
  it("Successfully checks equivalence of two distinct PRN objects", async () => {
91
91
  expect(
92
- new PRN("aa", "bb", ServiceAbbreviation.EMAILS_SERVICE, "cc", "dd").equals(
93
- new PRN("zz", "cd", ServiceAbbreviation.EMAILS_SERVICE, "ef", "gh"),
92
+ new PRN("aa", "bb", ServiceAbbreviation.PLATFORM_SERVICE, "cc", "dd").equals(
93
+ new PRN("zz", "cd", ServiceAbbreviation.PLATFORM_SERVICE, "ef", "gh"),
94
94
  ),
95
95
  ).toStrictEqual(false);
96
96
  });
97
97
 
98
98
  it("Successfully checks equivalence of one PRN object and a different object", async () => {
99
- expect(new PRN("aa", "bb", ServiceAbbreviation.EMAILS_SERVICE, "cc", "dd").equals(1234)).toStrictEqual(false);
99
+ expect(new PRN("aa", "bb", ServiceAbbreviation.PLATFORM_SERVICE, "cc", "dd").equals(1234)).toStrictEqual(false);
100
100
  });
101
101
  });
102
102
  });
@@ -16,7 +16,7 @@ export class PRN {
16
16
  public readonly organizationId: string;
17
17
 
18
18
  /**
19
- * Name of service that owns resource. E.g. 'cxc', 'oc'.
19
+ * Name of service that owns resource. E.g. 'cms', 'ps'.
20
20
  */
21
21
  public readonly service: ServiceAbbreviation;
22
22
 
@@ -9,12 +9,12 @@ describe("PRN_REGEX", () => {
9
9
  });
10
10
 
11
11
  it.each([
12
- `prn:plate:1:${ServiceAbbreviation.EMAILS_SERVICE}:-any:1234`,
13
- `prn:plate:12:${ServiceAbbreviation.ACCESS_CONTROL}:anything:a9ff417a-d8f7-1125-9ad7-7941d6222227`,
14
- `prn:plate:1:${ServiceAbbreviation.ORGANIZATIONS_CENTER}:-something_else:1234`,
15
- `prn:plate:1:${ServiceAbbreviation.CONTENT_EXPERIENCE_CENTER}:-any:8aaf417a-d8f7-4a6a-9ad7-7941d6222227`,
16
- `prn:plate:1:${ServiceAbbreviation.ASSET_MANAGER}:-any:some_id`,
17
- `prn:plate:1:${ServiceAbbreviation.CONTENT_EXPERIENCE_CENTER}:-any:someId`,
12
+ `prn:plate:1:${ServiceAbbreviation.PLATFORM_SERVICE}:-any:1234`,
13
+ `prn:plate:12:${ServiceAbbreviation.PLATFORM_SERVICE}:anything:a9ff417a-d8f7-1125-9ad7-7941d6222227`,
14
+ `prn:plate:1:${ServiceAbbreviation.PLATFORM_SERVICE}:-something_else:1234`,
15
+ `prn:plate:1:${ServiceAbbreviation.CONTENT_MANAGEMENT_SERVICE}:-any:8aaf417a-d8f7-4a6a-9ad7-7941d6222227`,
16
+ `prn:plate:1:${ServiceAbbreviation.PLATFORM_SERVICE}:-any:some_id`,
17
+ `prn:plate:1:${ServiceAbbreviation.CONTENT_MANAGEMENT_SERVICE}:-any:someId`,
18
18
  ])("accepts correct PRN string '%s'", async (prnString: string) => {
19
19
  // Act
20
20
  const result: boolean = prnRegex.test(prnString);
@@ -25,11 +25,11 @@ describe("PRN_REGEX", () => {
25
25
  });
26
26
 
27
27
  it.each([
28
- `not-prn:plate:-1:${ServiceAbbreviation.EMAILS_SERVICE}:any:1234`,
29
- `prn:plate:-1${ServiceAbbreviation.ACCESS_CONTROL}:too_little_components`,
30
- `prn:plate:-1:${ServiceAbbreviation.ORGANIZATIONS_CENTER}:any:1234:too_many_components`,
31
- `prn:plate:-1:${ServiceAbbreviation.CONTENT_EXPERIENCE_CENTER}:-any:`, // Empty component
32
- `prn:plate:-1:${ServiceAbbreviation.CONTENT_EXPERIENCE_CENTER}:has white space:1234`,
28
+ `not-prn:plate:-1:${ServiceAbbreviation.PLATFORM_SERVICE}:any:1234`,
29
+ `prn:plate:-1${ServiceAbbreviation.PLATFORM_SERVICE}:too_little_components`,
30
+ `prn:plate:-1:${ServiceAbbreviation.PLATFORM_SERVICE}:any:1234:too_many_components`,
31
+ `prn:plate:-1:${ServiceAbbreviation.CONTENT_MANAGEMENT_SERVICE}:-any:`, // Empty component
32
+ `prn:plate:-1:${ServiceAbbreviation.CONTENT_MANAGEMENT_SERVICE}:has white space:1234`,
33
33
  ])("denies incorrect PRN string '%s'", async (prnString: string) => {
34
34
  // Act
35
35
  const result: boolean = prnRegex.test(prnString);
@@ -1,7 +1,4 @@
1
1
  export enum ServiceAbbreviation {
2
- ASSET_MANAGER = "am",
3
- CONTENT_EXPERIENCE_CENTER = "cxc",
4
- ACCESS_CONTROL = "ac",
5
- EMAILS_SERVICE = "es",
6
- ORGANIZATIONS_CENTER = "oc",
2
+ CONTENT_MANAGEMENT_SERVICE = "cms",
3
+ PLATFORM_SERVICE = "ps",
7
4
  }
@@ -46,11 +46,11 @@ describe("TransformPrn", () => {
46
46
  }
47
47
 
48
48
  const testInstance = plainToInstance(TestClass, {
49
- testProperty: "prn:plate:-1:cxc:content-field:id",
49
+ testProperty: "prn:plate:-1:cms:content-field:id",
50
50
  });
51
51
 
52
52
  expect(testInstance.testProperty).toBeInstanceOf(PRN);
53
- expect(testInstance.testProperty.toString()).toStrictEqual("prn:plate:-1:cxc:content-field:id");
53
+ expect(testInstance.testProperty.toString()).toStrictEqual("prn:plate:-1:cms:content-field:id");
54
54
  });
55
55
 
56
56
  it("properly transforms an array of strings to an array of PRNs", () => {
@@ -60,14 +60,14 @@ describe("TransformPrn", () => {
60
60
  }
61
61
 
62
62
  const testInstance = plainToInstance(TestClass, {
63
- testProperty: ["prn:plate:-1:cxc:content-field:id", "prn:plate:-1:cxc:content-field:title"],
63
+ testProperty: ["prn:plate:-1:cms:content-field:id", "prn:plate:-1:cms:content-field:title"],
64
64
  });
65
65
 
66
66
  expect(testInstance.testProperty).toBeInstanceOf(Array);
67
67
  expect(testInstance.testProperty[0]).toBeInstanceOf(PRN);
68
68
  expect(testInstance.testProperty[1]).toBeInstanceOf(PRN);
69
- expect(testInstance.testProperty[0].toString()).toBe("prn:plate:-1:cxc:content-field:id");
70
- expect(testInstance.testProperty[1].toString()).toBe("prn:plate:-1:cxc:content-field:title");
69
+ expect(testInstance.testProperty[0].toString()).toBe("prn:plate:-1:cms:content-field:id");
70
+ expect(testInstance.testProperty[1].toString()).toBe("prn:plate:-1:cms:content-field:title");
71
71
  });
72
72
 
73
73
  it("properly transforms a PRN to a string", () => {
@@ -77,10 +77,10 @@ describe("TransformPrn", () => {
77
77
  }
78
78
 
79
79
  const testInstance = new TestClass();
80
- testInstance.testProperty = PRN.fromString("prn:plate:-1:cxc:content-field:id");
80
+ testInstance.testProperty = PRN.fromString("prn:plate:-1:cms:content-field:id");
81
81
 
82
82
  const plainObject = instanceToPlain(testInstance);
83
- expect(plainObject.testProperty).toBe("prn:plate:-1:cxc:content-field:id");
83
+ expect(plainObject.testProperty).toBe("prn:plate:-1:cms:content-field:id");
84
84
  });
85
85
 
86
86
  it("properly transforms an array of PRNs to an array of strings", () => {
@@ -91,16 +91,16 @@ describe("TransformPrn", () => {
91
91
 
92
92
  const testInstance = new TestClass();
93
93
  testInstance.testProperty = [
94
- PRN.fromString("prn:plate:-1:cxc:content-field:id"),
95
- PRN.fromString("prn:plate:-1:cxc:content-field:title"),
94
+ PRN.fromString("prn:plate:-1:cms:content-field:id"),
95
+ PRN.fromString("prn:plate:-1:cms:content-field:title"),
96
96
  ];
97
97
 
98
98
  const plainObject = instanceToPlain(testInstance) as {
99
99
  testProperty: unknown[];
100
100
  };
101
101
  expect(plainObject.testProperty).toBeInstanceOf(Array);
102
- expect(plainObject.testProperty[0]).toBe("prn:plate:-1:cxc:content-field:id");
103
- expect(plainObject.testProperty[1]).toBe("prn:plate:-1:cxc:content-field:title");
102
+ expect(plainObject.testProperty[0]).toBe("prn:plate:-1:cms:content-field:id");
103
+ expect(plainObject.testProperty[1]).toBe("prn:plate:-1:cms:content-field:title");
104
104
  });
105
105
 
106
106
  it.each([{ prnValue: null }, { prnValue: undefined }])(