@adobe/spacecat-shared-data-access 2.76.0 → 2.77.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 +14 -0
- package/package.json +1 -1
- package/src/models/audit/audit.schema.js +4 -0
- package/src/models/audit/index.d.ts +1 -0
- package/src/models/base/base.collection.js +8 -1
- package/src/models/base/index.d.ts +16 -4
- package/src/models/latest-audit/index.d.ts +1 -0
- package/src/models/latest-audit/latest-audit.schema.js +4 -0
- package/src/models/suggestion/index.d.ts +5 -5
package/CHANGELOG.md
CHANGED
|
@@ -1,3 +1,17 @@
|
|
|
1
|
+
# [@adobe/spacecat-shared-data-access-v2.77.0](https://github.com/adobe/spacecat-shared/compare/@adobe/spacecat-shared-data-access-v2.76.1...@adobe/spacecat-shared-data-access-v2.77.0) (2025-10-31)
|
|
2
|
+
|
|
3
|
+
|
|
4
|
+
### Features
|
|
5
|
+
|
|
6
|
+
* pagination base code ([#1077](https://github.com/adobe/spacecat-shared/issues/1077)) ([7cd3806](https://github.com/adobe/spacecat-shared/commit/7cd38061c74f5a6e73097e2ceabcd1e90bf8de3b))
|
|
7
|
+
|
|
8
|
+
# [@adobe/spacecat-shared-data-access-v2.76.1](https://github.com/adobe/spacecat-shared/compare/@adobe/spacecat-shared-data-access-v2.76.0...@adobe/spacecat-shared-data-access-v2.76.1) (2025-10-30)
|
|
9
|
+
|
|
10
|
+
|
|
11
|
+
### Bug Fixes
|
|
12
|
+
|
|
13
|
+
* **data-access:** include invocationId in audit schema ([#1075](https://github.com/adobe/spacecat-shared/issues/1075)) ([a7aecb2](https://github.com/adobe/spacecat-shared/commit/a7aecb211482e379ec77c20efbe672988071c660))
|
|
14
|
+
|
|
1
15
|
# [@adobe/spacecat-shared-data-access-v2.76.0](https://github.com/adobe/spacecat-shared/compare/@adobe/spacecat-shared-data-access-v2.75.0...@adobe/spacecat-shared-data-access-v2.76.0) (2025-10-29)
|
|
2
16
|
|
|
3
17
|
|
package/package.json
CHANGED
|
@@ -20,6 +20,7 @@ export interface Audit extends BaseModel {
|
|
|
20
20
|
getAuditResult(): object | [];
|
|
21
21
|
getAuditType(): string;
|
|
22
22
|
getFullAuditRef(): string;
|
|
23
|
+
getInvocationId(): string;
|
|
23
24
|
getIsError(): boolean;
|
|
24
25
|
getIsLive(): boolean;
|
|
25
26
|
getLatestAudit(): Promise<LatestAudit | null>;
|
|
@@ -237,6 +237,7 @@ class BaseCollection {
|
|
|
237
237
|
order: options.order || 'desc',
|
|
238
238
|
...options.limit && { limit: options.limit },
|
|
239
239
|
...options.attributes && { attributes: options.attributes },
|
|
240
|
+
...options.cursor && { cursor: options.cursor },
|
|
240
241
|
};
|
|
241
242
|
|
|
242
243
|
let query = index(keys);
|
|
@@ -268,10 +269,16 @@ class BaseCollection {
|
|
|
268
269
|
}
|
|
269
270
|
}
|
|
270
271
|
|
|
272
|
+
// Return cursor when explicitly requested via returnCursor option
|
|
273
|
+
const shouldReturnCursor = options.returnCursor === true;
|
|
274
|
+
|
|
271
275
|
if (options.limit === 1) {
|
|
272
276
|
return allData.length ? this.#createInstance(allData[0]) : null;
|
|
273
277
|
} else {
|
|
274
|
-
|
|
278
|
+
const instances = this.#createInstances(allData);
|
|
279
|
+
return shouldReturnCursor
|
|
280
|
+
? { data: instances, cursor: result.cursor || null }
|
|
281
|
+
: instances;
|
|
275
282
|
}
|
|
276
283
|
} catch (error) {
|
|
277
284
|
return this.#logAndThrowError('Failed to query', error);
|
|
@@ -34,13 +34,25 @@ export interface QueryOptions {
|
|
|
34
34
|
limit?: number;
|
|
35
35
|
order?: string;
|
|
36
36
|
attributes?: string[];
|
|
37
|
-
|
|
38
|
-
|
|
37
|
+
cursor?: string;
|
|
38
|
+
/**
|
|
39
|
+
* Whether to automatically fetch all pages of results.
|
|
39
40
|
* - `true`: Always paginate through all results
|
|
40
41
|
* - `false`: Only fetch first page
|
|
41
42
|
* - `undefined`: Auto-paginate when no limit specified, respect limits otherwise
|
|
42
43
|
*/
|
|
43
44
|
fetchAllPages?: boolean;
|
|
45
|
+
/**
|
|
46
|
+
* Whether to return cursor information for manual pagination.
|
|
47
|
+
* - `true`: Returns { data, cursor } for paginated results
|
|
48
|
+
* - `false` or `undefined`: Returns data array directly (default)
|
|
49
|
+
*/
|
|
50
|
+
returnCursor?: boolean;
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
export interface PaginatedResult<T> {
|
|
54
|
+
data: T[];
|
|
55
|
+
cursor: string | null;
|
|
44
56
|
}
|
|
45
57
|
|
|
46
58
|
export interface BatchGetOptions {
|
|
@@ -51,8 +63,8 @@ export interface BaseCollection<T extends BaseModel> {
|
|
|
51
63
|
_onCreate(item: T): void;
|
|
52
64
|
_onCreateMany(items: MultiStatusCreateResult<T>): void;
|
|
53
65
|
_saveMany(items: T[]): Promise<T[]>;
|
|
54
|
-
all(sortKeys?: object, options?: QueryOptions): Promise<T[]
|
|
55
|
-
allByIndexKeys(keys: object, options?: QueryOptions): Promise<T[]
|
|
66
|
+
all(sortKeys?: object, options?: QueryOptions): Promise<T[] | PaginatedResult<T>>;
|
|
67
|
+
allByIndexKeys(keys: object, options?: QueryOptions): Promise<T[] | PaginatedResult<T>>;
|
|
56
68
|
batchGetByKeys(keys: object[], options?: BatchGetOptions): Promise<{ data: T[]; unprocessed: object[] }>;
|
|
57
69
|
create(item: object): Promise<T>;
|
|
58
70
|
createMany(items: object[], parent?: T): Promise<MultiStatusCreateResult<T>>;
|
|
@@ -21,6 +21,7 @@ export interface LatestAudit extends BaseModel {
|
|
|
21
21
|
getAuditResult(): object | [];
|
|
22
22
|
getAuditType(): string;
|
|
23
23
|
getFullAuditRef(): string;
|
|
24
|
+
getInvocationId(): string;
|
|
24
25
|
getIsError(): boolean;
|
|
25
26
|
getIsLive(): boolean;
|
|
26
27
|
getOpportunities(): Promise<Opportunity[]>;
|
|
@@ -63,6 +63,10 @@ const schema = new SchemaBuilder(LatestAudit, LatestAuditCollection)
|
|
|
63
63
|
required: true,
|
|
64
64
|
default: false,
|
|
65
65
|
})
|
|
66
|
+
.addAttribute('invocationId', {
|
|
67
|
+
type: 'string',
|
|
68
|
+
required: false,
|
|
69
|
+
})
|
|
66
70
|
.addAttribute('auditedAt', {
|
|
67
71
|
type: 'string',
|
|
68
72
|
required: true,
|
|
@@ -10,7 +10,7 @@
|
|
|
10
10
|
* governing permissions and limitations under the License.
|
|
11
11
|
*/
|
|
12
12
|
|
|
13
|
-
import type { BaseCollection, BaseModel, Opportunity, FixEntitySuggestion, FixEntity } from '../index';
|
|
13
|
+
import type { BaseCollection, BaseModel, Opportunity, FixEntitySuggestion, FixEntity, QueryOptions, PaginatedResult } from '../index';
|
|
14
14
|
|
|
15
15
|
export interface Suggestion extends BaseModel {
|
|
16
16
|
getData(): object;
|
|
@@ -28,10 +28,10 @@ export interface Suggestion extends BaseModel {
|
|
|
28
28
|
}
|
|
29
29
|
|
|
30
30
|
export interface SuggestionCollection extends BaseCollection<Suggestion> {
|
|
31
|
-
allByOpportunityId(opportunityId: string): Promise<Suggestion[]
|
|
32
|
-
allByOpportunityIdAndStatus(opportunityId: string, status: string): Promise<Suggestion[]
|
|
31
|
+
allByOpportunityId(opportunityId: string, options?: QueryOptions): Promise<Suggestion[] | PaginatedResult<Suggestion>>;
|
|
32
|
+
allByOpportunityIdAndStatus(opportunityId: string, status: string, options?: QueryOptions): Promise<Suggestion[] | PaginatedResult<Suggestion>>;
|
|
33
33
|
bulkUpdateStatus(suggestions: Suggestion[], status: string): Promise<Suggestion[]>;
|
|
34
|
-
findByOpportunityId(opportunityId: string): Promise<Suggestion | null>;
|
|
35
|
-
findByOpportunityIdAndStatus(opportunityId: string, status: string): Promise<Suggestion | null>;
|
|
34
|
+
findByOpportunityId(opportunityId: string, options?: QueryOptions): Promise<Suggestion | null>;
|
|
35
|
+
findByOpportunityIdAndStatus(opportunityId: string, status: string, options?: QueryOptions): Promise<Suggestion | null>;
|
|
36
36
|
getFixEntitiesBySuggestionId(suggestionId: string): Promise<{data: Array<FixEntity>, unprocessed: Array<string>}>;
|
|
37
37
|
}
|