@adobe/spacecat-shared-data-access 3.80.0 → 3.81.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.
Files changed (34) hide show
  1. package/CHANGELOG.md +6 -0
  2. package/package.json +1 -1
  3. package/src/models/base/entity.registry.js +15 -0
  4. package/src/models/idempotency-key/idempotency-key.collection.js +89 -0
  5. package/src/models/idempotency-key/idempotency-key.model.js +41 -0
  6. package/src/models/idempotency-key/idempotency-key.schema.js +51 -0
  7. package/src/models/idempotency-key/index.d.ts +41 -0
  8. package/src/models/idempotency-key/index.js +19 -0
  9. package/src/models/index.d.ts +5 -0
  10. package/src/models/index.js +5 -0
  11. package/src/models/oauth-nonce/index.d.ts +26 -0
  12. package/src/models/oauth-nonce/index.js +19 -0
  13. package/src/models/oauth-nonce/oauth-nonce.collection.js +59 -0
  14. package/src/models/oauth-nonce/oauth-nonce.model.js +35 -0
  15. package/src/models/oauth-nonce/oauth-nonce.schema.js +50 -0
  16. package/src/models/organization/index.d.ts +3 -1
  17. package/src/models/organization/organization.schema.js +1 -0
  18. package/src/models/task-management-connection/index.d.ts +82 -0
  19. package/src/models/task-management-connection/index.js +21 -0
  20. package/src/models/task-management-connection/metadata-validator.js +97 -0
  21. package/src/models/task-management-connection/task-management-connection.collection.js +61 -0
  22. package/src/models/task-management-connection/task-management-connection.model.js +119 -0
  23. package/src/models/task-management-connection/task-management-connection.schema.js +111 -0
  24. package/src/models/ticket/index.d.ts +40 -0
  25. package/src/models/ticket/index.js +19 -0
  26. package/src/models/ticket/ticket.collection.js +30 -0
  27. package/src/models/ticket/ticket.model.js +44 -0
  28. package/src/models/ticket/ticket.schema.js +72 -0
  29. package/src/models/ticket-suggestion/index.d.ts +26 -0
  30. package/src/models/ticket-suggestion/index.js +19 -0
  31. package/src/models/ticket-suggestion/ticket-suggestion.collection.js +29 -0
  32. package/src/models/ticket-suggestion/ticket-suggestion.model.js +36 -0
  33. package/src/models/ticket-suggestion/ticket-suggestion.schema.js +53 -0
  34. package/src/service/index.d.ts +10 -0
@@ -0,0 +1,36 @@
1
+ /*
2
+ * Copyright 2026 Adobe. All rights reserved.
3
+ * This file is licensed to you under the Apache License, Version 2.0 (the "License");
4
+ * you may not use this file except in compliance with the License. You may obtain a copy
5
+ * of the License at http://www.apache.org/licenses/LICENSE-2.0
6
+ *
7
+ * Unless required by applicable law or agreed to in writing, software distributed under
8
+ * the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS
9
+ * OF ANY KIND, either express or implied. See the License for the specific language
10
+ * governing permissions and limitations under the License.
11
+ */
12
+
13
+ import BaseModel from '../base/base.model.js';
14
+
15
+ /**
16
+ * TicketSuggestion — bridge record linking a Suggestion to the Ticket created for it.
17
+ *
18
+ * Enforces 1:1 in v1: `UNIQUE (suggestion_id)` at the DB level prevents the same
19
+ * suggestion from being ticketed twice. In v2, the constraint relaxes to
20
+ * `UNIQUE (suggestion_id, ticket_id)` to support grouped ticket creation (M:N).
21
+ *
22
+ * `suggestionId` is a logical reference (stored as TEXT), not a Postgres FK.
23
+ * Suggestions live in DynamoDB/ElectroDB — there is no Postgres FK to enforce.
24
+ * Application-layer validation ensures the suggestion exists before creating this record.
25
+ *
26
+ * `opportunityId` is stored for direct opportunity-scoped queries without requiring
27
+ * a JOIN through the Ticket row.
28
+ *
29
+ * @class TicketSuggestion
30
+ * @extends BaseModel
31
+ */
32
+ class TicketSuggestion extends BaseModel {
33
+ static ENTITY_NAME = 'TicketSuggestion';
34
+ }
35
+
36
+ export default TicketSuggestion;
@@ -0,0 +1,53 @@
1
+ /*
2
+ * Copyright 2026 Adobe. All rights reserved.
3
+ * This file is licensed to you under the Apache License, Version 2.0 (the "License");
4
+ * you may not use this file except in compliance with the License. You may obtain a copy
5
+ * of the License at http://www.apache.org/licenses/LICENSE-2.0
6
+ *
7
+ * Unless required by applicable law or agreed to in writing, software distributed under
8
+ * the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS
9
+ * OF ANY KIND, either express or implied. See the License for the specific language
10
+ * governing permissions and limitations under the License.
11
+ */
12
+
13
+ /* c8 ignore start */
14
+
15
+ import SchemaBuilder from '../base/schema.builder.js';
16
+ import TicketSuggestion from './ticket-suggestion.model.js';
17
+ import TicketSuggestionCollection from './ticket-suggestion.collection.js';
18
+
19
+ // GSI on suggestionId powers findBySuggestionId() — used to check if a
20
+ // suggestion has already been ticketed before attempting to create a duplicate.
21
+ const schema = new SchemaBuilder(TicketSuggestion, TicketSuggestionCollection)
22
+ // ticket_suggestions is append-only — the DB grants no UPDATE privilege (bridge rows are
23
+ // immutable once created; delete and recreate if wrong). Disabling updates at the model
24
+ // layer surfaces a clean ValidationError instead of an opaque PostgREST 403.
25
+ .allowUpdates(false)
26
+ // ticket_suggestions is append-only — no updated_at or updated_by columns in the DB.
27
+ // Suppress the SchemaBuilder auto-added attributes so they are not included in INSERTs.
28
+ .addAttribute('updatedAt', {
29
+ type: 'string', required: false, readOnly: true, postgrestIgnore: true,
30
+ })
31
+ .addAttribute('updatedBy', { type: 'string', required: false, postgrestIgnore: true })
32
+ .addReference('belongs_to', 'Ticket')
33
+ .addAttribute('suggestionId', {
34
+ type: 'string',
35
+ required: true,
36
+ readOnly: true,
37
+ })
38
+ .addAttribute('opportunityId', {
39
+ type: 'string',
40
+ required: true,
41
+ readOnly: true,
42
+ })
43
+ .addAttribute('createdBy', {
44
+ type: 'string',
45
+ required: true,
46
+ readOnly: true,
47
+ })
48
+ .addIndex(
49
+ { composite: ['suggestionId'] },
50
+ { composite: [] },
51
+ );
52
+
53
+ export default schema.build();
@@ -44,6 +44,11 @@ import type { SiteEnrollmentCollection } from '../models/site-enrollment';
44
44
  import type { SiteTopFormCollection } from '../models/site-top-form';
45
45
  import type { SiteTopPageCollection } from '../models/site-top-page';
46
46
  import type { SuggestionCollection } from '../models/suggestion';
47
+ import type { IdempotencyKeyCollection } from '../models/idempotency-key';
48
+ import type { OAuthNonceCollection } from '../models/oauth-nonce';
49
+ import type { TaskManagementConnectionCollection } from '../models/task-management-connection';
50
+ import type { TicketCollection } from '../models/ticket';
51
+ import type { TicketSuggestionCollection } from '../models/ticket-suggestion';
47
52
  import type { TrialUserCollection } from '../models/trial-user';
48
53
  import type { TrialUserActivityCollection } from '../models/trial-user-activity';
49
54
 
@@ -94,6 +99,11 @@ export interface DataAccess {
94
99
  SiteTopForm: SiteTopFormCollection;
95
100
  SiteTopPage: SiteTopPageCollection;
96
101
  Suggestion: SuggestionCollection;
102
+ IdempotencyKey: IdempotencyKeyCollection;
103
+ OAuthNonce: OAuthNonceCollection;
104
+ TaskManagementConnection: TaskManagementConnectionCollection;
105
+ Ticket: TicketCollection;
106
+ TicketSuggestion: TicketSuggestionCollection;
97
107
  TrialUser: TrialUserCollection;
98
108
  TrialUserActivity: TrialUserActivityCollection;
99
109
  }