@adobe/spacecat-shared-data-access 3.58.0 → 3.60.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/CHANGELOG.md CHANGED
@@ -1,3 +1,15 @@
1
+ ## [@adobe/spacecat-shared-data-access-v3.60.0](https://github.com/adobe/spacecat-shared/compare/@adobe/spacecat-shared-data-access-v3.59.0...@adobe/spacecat-shared-data-access-v3.60.0) (2026-05-11)
2
+
3
+ ### Features
4
+
5
+ * **data-access:** add llmBackend field to Organization entity ([#1588](https://github.com/adobe/spacecat-shared/issues/1588)) ([ebccbe5](https://github.com/adobe/spacecat-shared/commit/ebccbe55688fb4b8fb3ffd76cc29650c2cc2fc65)), closes [mysticat-data-service#534](https://github.com/adobe/mysticat-data-service/issues/534)
6
+
7
+ ## [@adobe/spacecat-shared-data-access-v3.59.0](https://github.com/adobe/spacecat-shared/compare/@adobe/spacecat-shared-data-access-v3.58.0...@adobe/spacecat-shared-data-access-v3.59.0) (2026-05-07)
8
+
9
+ ### Features
10
+
11
+ * **data-access:** add Token.allBySiteId with optional tokenTypes/cycle filters ([#1572](https://github.com/adobe/spacecat-shared/issues/1572)) ([241607e](https://github.com/adobe/spacecat-shared/commit/241607e58c6b040eeaba134d51345ccd88910756))
12
+
1
13
  ## [@adobe/spacecat-shared-data-access-v3.58.0](https://github.com/adobe/spacecat-shared/compare/@adobe/spacecat-shared-data-access-v3.57.0...@adobe/spacecat-shared-data-access-v3.58.0) (2026-05-05)
2
14
 
3
15
  ### Features
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@adobe/spacecat-shared-data-access",
3
- "version": "3.58.0",
3
+ "version": "3.60.0",
4
4
  "description": "Shared modules of the Spacecat Services - Data Access",
5
5
  "type": "module",
6
6
  "engines": {
@@ -24,7 +24,15 @@ class Organization extends BaseModel {
24
24
 
25
25
  static IMS_ORG_ID_REGEX = /[a-z0-9]{24}@AdobeOrg/i;
26
26
 
27
- // add your custom methods or overrides here
27
+ static LLM_BACKEND_AZURE = 'azure';
28
+
29
+ static LLM_BACKEND_BEDROCK = 'bedrock';
30
+
31
+ static LLM_BACKENDS = ['azure', 'bedrock'];
32
+
33
+ getLlmBackend() {
34
+ return this.record.llmBackend ?? Organization.LLM_BACKEND_AZURE;
35
+ }
28
36
  }
29
37
 
30
38
  export default Organization;
@@ -40,6 +40,10 @@ const schema = new SchemaBuilder(Organization, OrganizationCollection)
40
40
  type: 'string',
41
41
  validate: (value) => !value || Organization.IMS_ORG_ID_REGEX.test(value),
42
42
  })
43
+ .addAttribute('llmBackend', {
44
+ type: Organization.LLM_BACKENDS,
45
+ validate: (value) => !value || Organization.LLM_BACKENDS.includes(value),
46
+ })
43
47
  .addAttribute('fulfillableItems', {
44
48
  type: 'any',
45
49
  validate: (value) => !value || isNonEmptyObject(value),
@@ -10,7 +10,7 @@
10
10
  * governing permissions and limitations under the License.
11
11
  */
12
12
 
13
- import { hasText, getTokenGrantConfig } from '@adobe/spacecat-shared-utils';
13
+ import { hasText, isNonEmptyArray, getTokenGrantConfig } from '@adobe/spacecat-shared-utils';
14
14
 
15
15
  import BaseCollection from '../base/base.collection.js';
16
16
  import DataAccessError from '../../errors/data-access.error.js';
@@ -66,6 +66,44 @@ class TokenCollection extends BaseCollection {
66
66
  used: 0,
67
67
  });
68
68
  }
69
+
70
+ /**
71
+ * Finds Tokens for the given siteId, optionally narrowed by tokenTypes and/or
72
+ * cycle. Issued as a single PostgREST query; all combinations are index-backed:
73
+ * - siteId + cycle → (site_id, cycle) index
74
+ * - siteId + cycle + types → (site_id, cycle) index + IN filter
75
+ * - siteId + types → (site_id, token_type, cycle) unique index prefix
76
+ * - siteId only → (site_id, …) prefix scan
77
+ *
78
+ * @param {string} siteId - Site ID (UUID).
79
+ * @param {Object} [options={}] - Query and filter options.
80
+ * @param {string[]} [options.tokenTypes] - Optional non-empty array of token
81
+ * type strings. When omitted, returns rows for all token types.
82
+ * @param {string} [options.cycle] - Optional cycle string (e.g. '2025-03').
83
+ * When omitted, returns rows for all cycles.
84
+ * @returns {Promise<import('./token.model.js').default[]>} Array of Token instances.
85
+ */
86
+ async allBySiteId(siteId, options = {}) {
87
+ if (!hasText(siteId)) {
88
+ throw new DataAccessError('TokenCollection.allBySiteId: siteId is required');
89
+ }
90
+ const { tokenTypes, cycle, ...queryOptions } = options;
91
+ const hasTypeFilter = tokenTypes != null;
92
+ if (hasTypeFilter && (!isNonEmptyArray(tokenTypes) || !tokenTypes.every(hasText))) {
93
+ throw new DataAccessError('TokenCollection.allBySiteId: tokenTypes must be a non-empty array of strings when provided');
94
+ }
95
+ if (cycle != null && !hasText(cycle)) {
96
+ throw new DataAccessError('TokenCollection.allBySiteId: cycle must be a non-empty string when provided');
97
+ }
98
+ const keys = { siteId };
99
+ if (hasText(cycle)) {
100
+ keys.cycle = cycle;
101
+ }
102
+ if (hasTypeFilter) {
103
+ queryOptions.where = (attrs, op) => op.in(attrs.tokenType, tokenTypes);
104
+ }
105
+ return this.all(keys, queryOptions);
106
+ }
69
107
  }
70
108
 
71
109
  export default TokenCollection;