@stackframe/stack-shared 2.8.39 → 2.8.41
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 +12 -0
- package/dist/esm/interface/client-interface.js +1 -1
- package/dist/esm/interface/client-interface.js.map +1 -1
- package/dist/esm/schema-fields.js +17 -1
- package/dist/esm/schema-fields.js.map +1 -1
- package/dist/esm/sessions.js +34 -12
- package/dist/esm/sessions.js.map +1 -1
- package/dist/esm/utils/paginated-lists.js +230 -0
- package/dist/esm/utils/paginated-lists.js.map +1 -0
- package/dist/helpers/password.d.mts +3 -3
- package/dist/helpers/password.d.ts +3 -3
- package/dist/index.d.mts +4 -5
- package/dist/index.d.ts +4 -5
- package/dist/interface/admin-interface.d.mts +4 -5
- package/dist/interface/admin-interface.d.ts +4 -5
- package/dist/interface/client-interface.d.mts +0 -1
- package/dist/interface/client-interface.d.ts +0 -1
- package/dist/interface/client-interface.js +1 -1
- package/dist/interface/client-interface.js.map +1 -1
- package/dist/interface/crud/current-user.d.mts +4 -4
- package/dist/interface/crud/current-user.d.ts +4 -4
- package/dist/interface/crud/oauth-providers.d.mts +4 -4
- package/dist/interface/crud/oauth-providers.d.ts +4 -4
- package/dist/interface/crud/project-api-keys.d.mts +2 -2
- package/dist/interface/crud/project-api-keys.d.ts +2 -2
- package/dist/interface/crud/projects.d.mts +12 -12
- package/dist/interface/crud/projects.d.ts +12 -12
- package/dist/interface/crud/team-member-profiles.d.mts +6 -6
- package/dist/interface/crud/team-member-profiles.d.ts +6 -6
- package/dist/interface/crud/transactions.d.mts +1 -1
- package/dist/interface/crud/transactions.d.ts +1 -1
- package/dist/interface/crud/users.d.mts +6 -6
- package/dist/interface/crud/users.d.ts +6 -6
- package/dist/interface/server-interface.d.mts +0 -1
- package/dist/interface/server-interface.d.ts +0 -1
- package/dist/known-errors.d.mts +3 -3
- package/dist/known-errors.d.ts +3 -3
- package/dist/schema-fields.d.mts +36 -7
- package/dist/schema-fields.d.ts +36 -7
- package/dist/schema-fields.js +19 -2
- package/dist/schema-fields.js.map +1 -1
- package/dist/sessions.d.mts +28 -5
- package/dist/sessions.d.ts +28 -5
- package/dist/sessions.js +33 -11
- package/dist/sessions.js.map +1 -1
- package/dist/utils/paginated-lists.d.mts +176 -0
- package/dist/utils/paginated-lists.d.ts +176 -0
- package/dist/utils/paginated-lists.js +256 -0
- package/dist/utils/paginated-lists.js.map +1 -0
- package/dist/utils/stores.d.mts +6 -6
- package/dist/utils/stores.d.ts +6 -6
- package/package.json +1 -1
|
@@ -0,0 +1,230 @@
|
|
|
1
|
+
// src/utils/paginated-lists.tsx
|
|
2
|
+
import { range } from "./arrays.js";
|
|
3
|
+
import { StackAssertionError } from "./errors.js";
|
|
4
|
+
var PaginatedList = class _PaginatedList {
|
|
5
|
+
// Implementations
|
|
6
|
+
getFirstCursor() {
|
|
7
|
+
return this._getFirstCursor();
|
|
8
|
+
}
|
|
9
|
+
getLastCursor() {
|
|
10
|
+
return this._getLastCursor();
|
|
11
|
+
}
|
|
12
|
+
compare(orderBy, a, b) {
|
|
13
|
+
return this._compare(orderBy, a, b);
|
|
14
|
+
}
|
|
15
|
+
async nextOrPrev(type, options) {
|
|
16
|
+
let result = [];
|
|
17
|
+
let includesFirst = false;
|
|
18
|
+
let includesLast = false;
|
|
19
|
+
let cursor = options.cursor;
|
|
20
|
+
let limitRemaining = options.limit;
|
|
21
|
+
while (limitRemaining > 0 || type === "next" && includesLast || type === "prev" && includesFirst) {
|
|
22
|
+
const iterationRes = await this._nextOrPrev(type, {
|
|
23
|
+
cursor,
|
|
24
|
+
limit: options.limit,
|
|
25
|
+
limitPrecision: "approximate",
|
|
26
|
+
filter: options.filter,
|
|
27
|
+
orderBy: options.orderBy
|
|
28
|
+
});
|
|
29
|
+
result[type === "next" ? "push" : "unshift"](...iterationRes.items);
|
|
30
|
+
limitRemaining -= iterationRes.items.length;
|
|
31
|
+
includesFirst ||= iterationRes.isFirst;
|
|
32
|
+
includesLast ||= iterationRes.isLast;
|
|
33
|
+
cursor = iterationRes.cursor;
|
|
34
|
+
if (["approximate", "at-most"].includes(options.limitPrecision)) break;
|
|
35
|
+
}
|
|
36
|
+
for (let i = 1; i < result.length; i++) {
|
|
37
|
+
if (this._compare(options.orderBy, result[i].item, result[i - 1].item) < 0) {
|
|
38
|
+
throw new StackAssertionError("Paginated list result is not sorted; something is wrong with the implementation", {
|
|
39
|
+
i,
|
|
40
|
+
options,
|
|
41
|
+
result
|
|
42
|
+
});
|
|
43
|
+
}
|
|
44
|
+
}
|
|
45
|
+
if (["exact", "at-most"].includes(options.limitPrecision) && result.length > options.limit) {
|
|
46
|
+
if (type === "next") {
|
|
47
|
+
result = result.slice(0, options.limit);
|
|
48
|
+
includesLast = false;
|
|
49
|
+
if (options.limit > 0) cursor = result[result.length - 1].itemCursor;
|
|
50
|
+
} else {
|
|
51
|
+
result = result.slice(result.length - options.limit);
|
|
52
|
+
includesFirst = false;
|
|
53
|
+
if (options.limit > 0) cursor = result[0].itemCursor;
|
|
54
|
+
}
|
|
55
|
+
}
|
|
56
|
+
return { items: result, isFirst: includesFirst, isLast: includesLast, cursor };
|
|
57
|
+
}
|
|
58
|
+
async next({ after, ...rest }) {
|
|
59
|
+
return await this.nextOrPrev("next", {
|
|
60
|
+
...rest,
|
|
61
|
+
cursor: after
|
|
62
|
+
});
|
|
63
|
+
}
|
|
64
|
+
async prev({ before, ...rest }) {
|
|
65
|
+
return await this.nextOrPrev("prev", {
|
|
66
|
+
...rest,
|
|
67
|
+
cursor: before
|
|
68
|
+
});
|
|
69
|
+
}
|
|
70
|
+
// Utility methods below
|
|
71
|
+
flatMap(options) {
|
|
72
|
+
const that = this;
|
|
73
|
+
class FlatMapPaginatedList extends _PaginatedList {
|
|
74
|
+
_getFirstCursor() {
|
|
75
|
+
return options.newCursorFromOldCursor(that.getFirstCursor());
|
|
76
|
+
}
|
|
77
|
+
_getLastCursor() {
|
|
78
|
+
return options.newCursorFromOldCursor(that.getLastCursor());
|
|
79
|
+
}
|
|
80
|
+
_compare(orderBy, a, b) {
|
|
81
|
+
return options.compare(orderBy, a, b);
|
|
82
|
+
}
|
|
83
|
+
async _nextOrPrev(type, { limit, filter, orderBy, cursor }) {
|
|
84
|
+
const estimatedItems = options.estimateItemsToFetch({ limit, filter, orderBy });
|
|
85
|
+
const original = await that.nextOrPrev(type, {
|
|
86
|
+
limit: estimatedItems,
|
|
87
|
+
limitPrecision: "approximate",
|
|
88
|
+
cursor: options.oldCursorFromNewCursor(cursor),
|
|
89
|
+
filter: options.oldFilterFromNewFilter(filter),
|
|
90
|
+
orderBy: options.oldOrderByFromNewOrderBy(orderBy)
|
|
91
|
+
});
|
|
92
|
+
const mapped = original.items.flatMap((itemEntry) => options.itemMapper(
|
|
93
|
+
itemEntry,
|
|
94
|
+
filter,
|
|
95
|
+
orderBy
|
|
96
|
+
));
|
|
97
|
+
return {
|
|
98
|
+
items: mapped,
|
|
99
|
+
isFirst: original.isFirst,
|
|
100
|
+
isLast: original.isLast,
|
|
101
|
+
cursor: options.newCursorFromOldCursor(original.cursor)
|
|
102
|
+
};
|
|
103
|
+
}
|
|
104
|
+
}
|
|
105
|
+
return new FlatMapPaginatedList();
|
|
106
|
+
}
|
|
107
|
+
map(options) {
|
|
108
|
+
return this.flatMap({
|
|
109
|
+
itemMapper: (itemEntry, filter, orderBy) => {
|
|
110
|
+
return [{ item: options.itemMapper(itemEntry.item), itemCursor: itemEntry.itemCursor }];
|
|
111
|
+
},
|
|
112
|
+
compare: (orderBy, a, b) => this.compare(options.oldOrderByFromNewOrderBy(orderBy), options.oldItemFromNewItem(a), options.oldItemFromNewItem(b)),
|
|
113
|
+
newCursorFromOldCursor: (cursor) => cursor,
|
|
114
|
+
oldCursorFromNewCursor: (cursor) => cursor,
|
|
115
|
+
oldFilterFromNewFilter: (filter) => options.oldFilterFromNewFilter(filter),
|
|
116
|
+
oldOrderByFromNewOrderBy: (orderBy) => options.oldOrderByFromNewOrderBy(orderBy),
|
|
117
|
+
estimateItemsToFetch: (options2) => options2.limit
|
|
118
|
+
});
|
|
119
|
+
}
|
|
120
|
+
filter(options) {
|
|
121
|
+
return this.flatMap({
|
|
122
|
+
itemMapper: (itemEntry, filter, orderBy) => options.filter(itemEntry.item, filter) ? [itemEntry] : [],
|
|
123
|
+
compare: (orderBy, a, b) => this.compare(orderBy, a, b),
|
|
124
|
+
newCursorFromOldCursor: (cursor) => cursor,
|
|
125
|
+
oldCursorFromNewCursor: (cursor) => cursor,
|
|
126
|
+
oldFilterFromNewFilter: (filter) => options.oldFilterFromNewFilter(filter),
|
|
127
|
+
oldOrderByFromNewOrderBy: (orderBy) => orderBy,
|
|
128
|
+
estimateItemsToFetch: (o) => options.estimateItemsToFetch(o)
|
|
129
|
+
});
|
|
130
|
+
}
|
|
131
|
+
addFilter(options) {
|
|
132
|
+
return this.filter({
|
|
133
|
+
filter: (item, filter) => options.filter(item, filter),
|
|
134
|
+
oldFilterFromNewFilter: (filter) => filter,
|
|
135
|
+
estimateItemsToFetch: (o) => options.estimateItemsToFetch(o)
|
|
136
|
+
});
|
|
137
|
+
}
|
|
138
|
+
static merge(...lists) {
|
|
139
|
+
class MergePaginatedList extends _PaginatedList {
|
|
140
|
+
_getFirstCursor() {
|
|
141
|
+
return JSON.stringify(lists.map((list) => list.getFirstCursor()));
|
|
142
|
+
}
|
|
143
|
+
_getLastCursor() {
|
|
144
|
+
return JSON.stringify(lists.map((list) => list.getLastCursor()));
|
|
145
|
+
}
|
|
146
|
+
_compare(orderBy, a, b) {
|
|
147
|
+
const listsResults = lists.map((list) => list.compare(orderBy, a, b));
|
|
148
|
+
if (!listsResults.every((result) => result === listsResults[0])) {
|
|
149
|
+
throw new StackAssertionError("Lists have different compare results; make sure that they use the same compare function", { lists, listsResults });
|
|
150
|
+
}
|
|
151
|
+
return listsResults[0];
|
|
152
|
+
}
|
|
153
|
+
async _nextOrPrev(type, { limit, filter, orderBy, cursor }) {
|
|
154
|
+
const cursors = JSON.parse(cursor);
|
|
155
|
+
const fetchedLists = await Promise.all(lists.map(async (list, i) => {
|
|
156
|
+
return await list.nextOrPrev(type, {
|
|
157
|
+
limit,
|
|
158
|
+
filter,
|
|
159
|
+
orderBy,
|
|
160
|
+
cursor: cursors[i],
|
|
161
|
+
limitPrecision: "at-least"
|
|
162
|
+
});
|
|
163
|
+
}));
|
|
164
|
+
const combinedItems = fetchedLists.flatMap((list, i) => list.items.map((itemEntry) => ({ itemEntry, listIndex: i })));
|
|
165
|
+
const sortedItems = [...combinedItems].sort((a, b) => this._compare(orderBy, a.itemEntry.item, b.itemEntry.item));
|
|
166
|
+
const lastCursorForEachList = sortedItems.reduce((acc, item) => {
|
|
167
|
+
acc[item.listIndex] = item.itemEntry.itemCursor;
|
|
168
|
+
return acc;
|
|
169
|
+
}, range(lists.length).map((i) => cursors[i]));
|
|
170
|
+
return {
|
|
171
|
+
items: sortedItems.map((item) => item.itemEntry),
|
|
172
|
+
isFirst: sortedItems.every((item) => item.listIndex === 0),
|
|
173
|
+
isLast: sortedItems.every((item) => item.listIndex === lists.length - 1),
|
|
174
|
+
cursor: JSON.stringify(lastCursorForEachList)
|
|
175
|
+
};
|
|
176
|
+
}
|
|
177
|
+
}
|
|
178
|
+
return new MergePaginatedList();
|
|
179
|
+
}
|
|
180
|
+
static empty() {
|
|
181
|
+
class EmptyPaginatedList extends _PaginatedList {
|
|
182
|
+
_getFirstCursor() {
|
|
183
|
+
return "first";
|
|
184
|
+
}
|
|
185
|
+
_getLastCursor() {
|
|
186
|
+
return "last";
|
|
187
|
+
}
|
|
188
|
+
_compare(orderBy, a, b) {
|
|
189
|
+
return 0;
|
|
190
|
+
}
|
|
191
|
+
async _nextOrPrev(type, options) {
|
|
192
|
+
return { items: [], isFirst: true, isLast: true, cursor: "first" };
|
|
193
|
+
}
|
|
194
|
+
}
|
|
195
|
+
return new EmptyPaginatedList();
|
|
196
|
+
}
|
|
197
|
+
};
|
|
198
|
+
var ArrayPaginatedList = class extends PaginatedList {
|
|
199
|
+
constructor(array) {
|
|
200
|
+
super();
|
|
201
|
+
this.array = array;
|
|
202
|
+
}
|
|
203
|
+
_getFirstCursor() {
|
|
204
|
+
return "0";
|
|
205
|
+
}
|
|
206
|
+
_getLastCursor() {
|
|
207
|
+
return `${this.array.length - 1}`;
|
|
208
|
+
}
|
|
209
|
+
_compare(orderBy, a, b) {
|
|
210
|
+
return orderBy(a, b);
|
|
211
|
+
}
|
|
212
|
+
async _nextOrPrev(type, options) {
|
|
213
|
+
const filteredArray = this.array.filter(options.filter);
|
|
214
|
+
const sortedArray = [...filteredArray].sort((a, b) => this._compare(options.orderBy, a, b));
|
|
215
|
+
const itemEntriesArray = sortedArray.map((item, index) => ({ item, itemCursor: `${index}` }));
|
|
216
|
+
const oldCursor = Number(options.cursor);
|
|
217
|
+
const newCursor = Math.max(0, Math.min(this.array.length - 1, oldCursor + (type === "next" ? 1 : -1) * options.limit));
|
|
218
|
+
return {
|
|
219
|
+
items: itemEntriesArray.slice(Math.min(oldCursor, newCursor), Math.max(oldCursor, newCursor)),
|
|
220
|
+
isFirst: oldCursor === 0 || newCursor === 0,
|
|
221
|
+
isLast: oldCursor === this.array.length - 1 || newCursor === this.array.length - 1,
|
|
222
|
+
cursor: `${newCursor}`
|
|
223
|
+
};
|
|
224
|
+
}
|
|
225
|
+
};
|
|
226
|
+
export {
|
|
227
|
+
ArrayPaginatedList,
|
|
228
|
+
PaginatedList
|
|
229
|
+
};
|
|
230
|
+
//# sourceMappingURL=paginated-lists.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../../src/utils/paginated-lists.tsx"],"sourcesContent":["import { range } from \"./arrays\";\nimport { StackAssertionError } from \"./errors\";\n\ntype QueryOptions<Type extends 'next' | 'prev', Cursor, Filter, OrderBy> =\n & {\n filter: Filter,\n orderBy: OrderBy,\n limit: number,\n /**\n * Whether the limit should be treated as an exact value, or an approximate value.\n *\n * If set to 'exact', less items will only be returned if the list item is the first or last item.\n *\n * If set to 'at-least' or 'approximate', the implementation may decide to return more items than the limit requested if doing so comes at no (or negligible) extra cost.\n *\n * If set to 'at-most' or 'approximate', the implementation may decide to return less items than the limit requested if requesting more items would come at a non-negligible extra cost. In this case, if limit > 0, the implementation must still make progress towards the end of the list and the returned cursor must be different from the one passed in.\n *\n * Defaults to 'exact'.\n */\n limitPrecision: 'exact' | 'at-least' | 'at-most' | 'approximate',\n }\n & ([Type] extends [never] ? unknown\n : [Type] extends ['next'] ? { after: Cursor }\n : [Type] extends ['prev'] ? { before: Cursor }\n : { cursor: Cursor });\n\ntype ImplQueryOptions<Type extends 'next' | 'prev', Cursor, Filter, OrderBy> = QueryOptions<Type, Cursor, Filter, OrderBy> & { limitPrecision: 'approximate' }\n\ntype QueryResult<Item, Cursor> = { items: { item: Item, itemCursor: Cursor }[], isFirst: boolean, isLast: boolean, cursor: Cursor }\n\ntype ImplQueryResult<Item, Cursor> = { items: { item: Item, itemCursor: Cursor }[], isFirst: boolean, isLast: boolean, cursor: Cursor }\n\nexport abstract class PaginatedList<\n Item,\n Cursor extends string,\n Filter extends unknown,\n OrderBy extends unknown,\n> {\n // Abstract methods\n\n protected abstract _getFirstCursor(): Cursor;\n protected abstract _getLastCursor(): Cursor;\n protected abstract _compare(orderBy: OrderBy, a: Item, b: Item): number;\n protected abstract _nextOrPrev(type: 'next' | 'prev', options: ImplQueryOptions<'next' | 'prev', Cursor, Filter, OrderBy>): Promise<ImplQueryResult<Item, Cursor>>;\n\n // Implementations\n public getFirstCursor(): Cursor { return this._getFirstCursor(); }\n public getLastCursor(): Cursor { return this._getLastCursor(); }\n public compare(orderBy: OrderBy, a: Item, b: Item): number { return this._compare(orderBy, a, b); }\n\n async nextOrPrev(type: 'next' | 'prev', options: QueryOptions<'next' | 'prev', Cursor, Filter, OrderBy>): Promise<QueryResult<Item, Cursor>> {\n let result: { item: Item, itemCursor: Cursor }[] = [];\n let includesFirst = false;\n let includesLast = false;\n let cursor = options.cursor;\n let limitRemaining = options.limit;\n while (limitRemaining > 0 || (type === \"next\" && includesLast) || (type === \"prev\" && includesFirst)) {\n const iterationRes = await this._nextOrPrev(type, {\n cursor,\n limit: options.limit,\n limitPrecision: \"approximate\",\n filter: options.filter,\n orderBy: options.orderBy,\n });\n result[type === \"next\" ? \"push\" : \"unshift\"](...iterationRes.items);\n limitRemaining -= iterationRes.items.length;\n includesFirst ||= iterationRes.isFirst;\n includesLast ||= iterationRes.isLast;\n cursor = iterationRes.cursor;\n if ([\"approximate\", \"at-most\"].includes(options.limitPrecision)) break;\n }\n\n // Assert that the result is sorted\n for (let i = 1; i < result.length; i++) {\n if (this._compare(options.orderBy, result[i].item, result[i - 1].item) < 0) {\n throw new StackAssertionError(\"Paginated list result is not sorted; something is wrong with the implementation\", {\n i,\n options,\n result,\n });\n }\n }\n\n if ([\"exact\", \"at-most\"].includes(options.limitPrecision) && result.length > options.limit) {\n if (type === \"next\") {\n result = result.slice(0, options.limit);\n includesLast = false;\n if (options.limit > 0) cursor = result[result.length - 1].itemCursor;\n } else {\n result = result.slice(result.length - options.limit);\n includesFirst = false;\n if (options.limit > 0) cursor = result[0].itemCursor;\n }\n }\n return { items: result, isFirst: includesFirst, isLast: includesLast, cursor };\n }\n public async next({ after, ...rest }: QueryOptions<'next', Cursor, Filter, OrderBy>): Promise<QueryResult<Item, Cursor>> {\n return await this.nextOrPrev(\"next\", {\n ...rest,\n cursor: after,\n });\n }\n public async prev({ before, ...rest }: QueryOptions<'prev', Cursor, Filter, OrderBy>): Promise<QueryResult<Item, Cursor>> {\n return await this.nextOrPrev(\"prev\", {\n ...rest,\n cursor: before,\n });\n }\n\n // Utility methods below\n\n flatMap<Item2, Cursor2 extends string, Filter2 extends unknown, OrderBy2 extends unknown>(options: {\n itemMapper: (itemEntry: { item: Item, itemCursor: Cursor }, filter: Filter2, orderBy: OrderBy2) => { item: Item2, itemCursor: Cursor2 }[],\n compare: (orderBy: OrderBy2, a: Item2, b: Item2) => number,\n newCursorFromOldCursor: (cursor: Cursor) => Cursor2,\n oldCursorFromNewCursor: (cursor: Cursor2) => Cursor,\n oldFilterFromNewFilter: (filter: Filter2) => Filter,\n oldOrderByFromNewOrderBy: (orderBy: OrderBy2) => OrderBy,\n estimateItemsToFetch: (options: { filter: Filter2, orderBy: OrderBy2, limit: number }) => number,\n }): PaginatedList<Item2, Cursor2, Filter2, OrderBy2> {\n const that = this;\n class FlatMapPaginatedList extends PaginatedList<Item2, Cursor2, Filter2, OrderBy2> {\n override _getFirstCursor(): Cursor2 { return options.newCursorFromOldCursor(that.getFirstCursor()); }\n override _getLastCursor(): Cursor2 { return options.newCursorFromOldCursor(that.getLastCursor()); }\n\n override _compare(orderBy: OrderBy2, a: Item2, b: Item2): number {\n return options.compare(orderBy, a, b);\n }\n\n override async _nextOrPrev(type: 'next' | 'prev', { limit, filter, orderBy, cursor }: ImplQueryOptions<'next' | 'prev', Cursor2, Filter2, OrderBy2>) {\n const estimatedItems = options.estimateItemsToFetch({ limit, filter, orderBy });\n const original = await that.nextOrPrev(type, {\n limit: estimatedItems,\n limitPrecision: \"approximate\",\n cursor: options.oldCursorFromNewCursor(cursor),\n filter: options.oldFilterFromNewFilter(filter),\n orderBy: options.oldOrderByFromNewOrderBy(orderBy),\n });\n const mapped = original.items.flatMap(itemEntry => options.itemMapper(\n itemEntry,\n filter,\n orderBy,\n ));\n return {\n items: mapped,\n isFirst: original.isFirst,\n isLast: original.isLast,\n cursor: options.newCursorFromOldCursor(original.cursor),\n };\n }\n }\n return new FlatMapPaginatedList();\n }\n\n map<Item2, Filter2 extends unknown, OrderBy2 extends unknown>(options: {\n itemMapper: (item: Item) => Item2,\n oldItemFromNewItem: (item: Item2) => Item,\n oldFilterFromNewFilter: (filter: Filter2) => Filter,\n oldOrderByFromNewOrderBy: (orderBy: OrderBy2) => OrderBy,\n }): PaginatedList<Item2, Cursor, Filter2, OrderBy2> {\n return this.flatMap({\n itemMapper: (itemEntry, filter, orderBy) => {\n return [{ item: options.itemMapper(itemEntry.item), itemCursor: itemEntry.itemCursor }];\n },\n compare: (orderBy, a, b) => this.compare(options.oldOrderByFromNewOrderBy(orderBy), options.oldItemFromNewItem(a), options.oldItemFromNewItem(b)),\n newCursorFromOldCursor: (cursor) => cursor,\n oldCursorFromNewCursor: (cursor) => cursor,\n oldFilterFromNewFilter: (filter) => options.oldFilterFromNewFilter(filter),\n oldOrderByFromNewOrderBy: (orderBy) => options.oldOrderByFromNewOrderBy(orderBy),\n estimateItemsToFetch: (options) => options.limit,\n });\n }\n\n filter<Filter2 extends unknown>(options: {\n filter: (item: Item, filter: Filter2) => boolean,\n oldFilterFromNewFilter: (filter: Filter2) => Filter,\n estimateItemsToFetch: (options: { filter: Filter2, orderBy: OrderBy, limit: number }) => number,\n }): PaginatedList<Item, Cursor, Filter2, OrderBy> {\n return this.flatMap({\n itemMapper: (itemEntry, filter, orderBy) => (options.filter(itemEntry.item, filter) ? [itemEntry] : []),\n compare: (orderBy, a, b) => this.compare(orderBy, a, b),\n newCursorFromOldCursor: (cursor) => cursor,\n oldCursorFromNewCursor: (cursor) => cursor,\n oldFilterFromNewFilter: (filter) => options.oldFilterFromNewFilter(filter),\n oldOrderByFromNewOrderBy: (orderBy) => orderBy,\n estimateItemsToFetch: (o) => options.estimateItemsToFetch(o),\n });\n }\n\n addFilter<AddedFilter extends unknown>(options: {\n filter: (item: Item, filter: Filter & AddedFilter) => boolean,\n estimateItemsToFetch: (options: { filter: Filter & AddedFilter, orderBy: OrderBy, limit: number }) => number,\n }): PaginatedList<Item, Cursor, Filter & AddedFilter, OrderBy> {\n return this.filter({\n filter: (item, filter) => options.filter(item, filter),\n oldFilterFromNewFilter: (filter) => filter,\n estimateItemsToFetch: (o) => options.estimateItemsToFetch(o),\n });\n }\n\n static merge<\n Item,\n Filter extends unknown,\n OrderBy extends unknown,\n >(\n ...lists: PaginatedList<Item, any, Filter, OrderBy>[]\n ): PaginatedList<Item, string, Filter, OrderBy> {\n class MergePaginatedList extends PaginatedList<Item, string, Filter, OrderBy> {\n override _getFirstCursor() { return JSON.stringify(lists.map(list => list.getFirstCursor())); }\n override _getLastCursor() { return JSON.stringify(lists.map(list => list.getLastCursor())); }\n override _compare(orderBy: OrderBy, a: Item, b: Item): number {\n const listsResults = lists.map(list => list.compare(orderBy, a, b));\n if (!listsResults.every(result => result === listsResults[0])) {\n throw new StackAssertionError(\"Lists have different compare results; make sure that they use the same compare function\", { lists, listsResults });\n }\n return listsResults[0];\n }\n\n override async _nextOrPrev(type: 'next' | 'prev', { limit, filter, orderBy, cursor }: ImplQueryOptions<'next' | 'prev', \"first\" | \"last\" | `[${string}]`, Filter, OrderBy>) {\n const cursors = JSON.parse(cursor);\n const fetchedLists = await Promise.all(lists.map(async (list, i) => {\n return await list.nextOrPrev(type, {\n limit,\n filter,\n orderBy,\n cursor: cursors[i],\n limitPrecision: \"at-least\",\n });\n }));\n const combinedItems = fetchedLists.flatMap((list, i) => list.items.map((itemEntry) => ({ itemEntry, listIndex: i })));\n const sortedItems = [...combinedItems].sort((a, b) => this._compare(orderBy, a.itemEntry.item, b.itemEntry.item));\n const lastCursorForEachList = sortedItems.reduce((acc, item) => {\n acc[item.listIndex] = item.itemEntry.itemCursor;\n return acc;\n }, range(lists.length).map((i) => cursors[i]));\n return {\n items: sortedItems.map((item) => item.itemEntry),\n isFirst: sortedItems.every((item) => item.listIndex === 0),\n isLast: sortedItems.every((item) => item.listIndex === lists.length - 1),\n cursor: JSON.stringify(lastCursorForEachList),\n };\n }\n }\n return new MergePaginatedList();\n }\n\n static empty() {\n class EmptyPaginatedList extends PaginatedList<never, \"first\" | \"last\", any, any> {\n override _getFirstCursor() { return \"first\" as const; }\n override _getLastCursor() { return \"last\" as const; }\n override _compare(orderBy: any, a: any, b: any): number {\n return 0;\n }\n override async _nextOrPrev(type: 'next' | 'prev', options: ImplQueryOptions<'next' | 'prev', string, any, any>) {\n return { items: [], isFirst: true, isLast: true, cursor: \"first\" as const };\n }\n }\n return new EmptyPaginatedList();\n }\n}\n\nexport class ArrayPaginatedList<Item> extends PaginatedList<Item, `${number}`, (item: Item) => boolean, (a: Item, b: Item) => number> {\n constructor(private readonly array: Item[]) {\n super();\n }\n\n override _getFirstCursor() { return \"0\" as const; }\n override _getLastCursor() { return `${this.array.length - 1}` as const; }\n override _compare(orderBy: (a: Item, b: Item) => number, a: Item, b: Item): number {\n return orderBy(a, b);\n }\n\n override async _nextOrPrev(type: 'next' | 'prev', options: ImplQueryOptions<'next' | 'prev', `${number}`, (item: Item) => boolean, (a: Item, b: Item) => number>) {\n const filteredArray = this.array.filter(options.filter);\n const sortedArray = [...filteredArray].sort((a, b) => this._compare(options.orderBy, a, b));\n const itemEntriesArray = sortedArray.map((item, index) => ({ item, itemCursor: `${index}` as const }));\n const oldCursor = Number(options.cursor);\n const newCursor = Math.max(0, Math.min(this.array.length - 1, oldCursor + (type === \"next\" ? 1 : -1) * options.limit));\n return {\n items: itemEntriesArray.slice(Math.min(oldCursor, newCursor), Math.max(oldCursor, newCursor)),\n isFirst: oldCursor === 0 || newCursor === 0,\n isLast: oldCursor === this.array.length - 1 || newCursor === this.array.length - 1,\n cursor: `${newCursor}` as const,\n };\n }\n}\n"],"mappings":";AAAA,SAAS,aAAa;AACtB,SAAS,2BAA2B;AA+B7B,IAAe,gBAAf,MAAe,eAKpB;AAAA;AAAA,EASO,iBAAyB;AAAE,WAAO,KAAK,gBAAgB;AAAA,EAAG;AAAA,EAC1D,gBAAwB;AAAE,WAAO,KAAK,eAAe;AAAA,EAAG;AAAA,EACxD,QAAQ,SAAkB,GAAS,GAAiB;AAAE,WAAO,KAAK,SAAS,SAAS,GAAG,CAAC;AAAA,EAAG;AAAA,EAElG,MAAM,WAAW,MAAuB,SAAqG;AAC3I,QAAI,SAA+C,CAAC;AACpD,QAAI,gBAAgB;AACpB,QAAI,eAAe;AACnB,QAAI,SAAS,QAAQ;AACrB,QAAI,iBAAiB,QAAQ;AAC7B,WAAO,iBAAiB,KAAM,SAAS,UAAU,gBAAkB,SAAS,UAAU,eAAgB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,EAAE,KAAK,CAAC,GAAG,MAAM,KAAK,SAAS,QAAQ,SAAS,GAAG,CAAC,CAAC;AAC1F,UAAM,mBAAmB,YAAY,IAAI,CAAC,MAAM,WAAW,EAAE,MAAM,YAAY,GAAG,KAAK,GAAY,EAAE;AACrG,UAAM,YAAY,OAAO,QAAQ,MAAM;AACvC,UAAM,YAAY,KAAK,IAAI,GAAG,KAAK,IAAI,KAAK,MAAM,SAAS,GAAG,aAAa,SAAS,SAAS,IAAI,MAAM,QAAQ,KAAK,CAAC;AACrH,WAAO;AAAA,MACL,OAAO,iBAAiB,MAAM,KAAK,IAAI,WAAW,SAAS,GAAG,KAAK,IAAI,WAAW,SAAS,CAAC;AAAA,MAC5F,SAAS,cAAc,KAAK,cAAc;AAAA,MAC1C,QAAQ,cAAc,KAAK,MAAM,SAAS,KAAK,cAAc,KAAK,MAAM,SAAS;AAAA,MACjF,QAAQ,GAAG,SAAS;AAAA,IACtB;AAAA,EACF;AACF;","names":["options"]}
|
|
@@ -1,14 +1,14 @@
|
|
|
1
1
|
import { KnownErrors } from '../known-errors.mjs';
|
|
2
|
-
import '../crud.mjs';
|
|
3
2
|
import '../schema-fields.mjs';
|
|
3
|
+
import '../crud.mjs';
|
|
4
4
|
import '../utils/errors.mjs';
|
|
5
5
|
import '../utils/json.mjs';
|
|
6
6
|
import '../utils/results.mjs';
|
|
7
7
|
import 'yup';
|
|
8
|
-
import '../utils/types.mjs';
|
|
9
|
-
import '../utils/strings.mjs';
|
|
10
8
|
import '../utils/currency-constants.mjs';
|
|
11
9
|
import '../utils/dates.mjs';
|
|
10
|
+
import '../utils/types.mjs';
|
|
11
|
+
import '../utils/strings.mjs';
|
|
12
12
|
|
|
13
13
|
declare function getPasswordError(password: string): KnownErrors["PasswordRequirementsNotMet"] | undefined;
|
|
14
14
|
|
|
@@ -1,14 +1,14 @@
|
|
|
1
1
|
import { KnownErrors } from '../known-errors.js';
|
|
2
|
-
import '../crud.js';
|
|
3
2
|
import '../schema-fields.js';
|
|
3
|
+
import '../crud.js';
|
|
4
4
|
import '../utils/errors.js';
|
|
5
5
|
import '../utils/json.js';
|
|
6
6
|
import '../utils/results.js';
|
|
7
7
|
import 'yup';
|
|
8
|
-
import '../utils/types.js';
|
|
9
|
-
import '../utils/strings.js';
|
|
10
8
|
import '../utils/currency-constants.js';
|
|
11
9
|
import '../utils/dates.js';
|
|
10
|
+
import '../utils/types.js';
|
|
11
|
+
import '../utils/strings.js';
|
|
12
12
|
|
|
13
13
|
declare function getPasswordError(password: string): KnownErrors["PasswordRequirementsNotMet"] | undefined;
|
|
14
14
|
|
package/dist/index.d.mts
CHANGED
|
@@ -3,11 +3,13 @@ export { StackClientInterface } from './interface/client-interface.mjs';
|
|
|
3
3
|
export { StackServerInterface } from './interface/server-interface.mjs';
|
|
4
4
|
export { KnownError, KnownErrors } from './known-errors.mjs';
|
|
5
5
|
import './sessions.mjs';
|
|
6
|
-
import '
|
|
6
|
+
import 'yup';
|
|
7
|
+
import './schema-fields.mjs';
|
|
8
|
+
import './utils/currency-constants.mjs';
|
|
9
|
+
import './utils/dates.mjs';
|
|
7
10
|
import './utils/results.mjs';
|
|
8
11
|
import './interface/crud/config.mjs';
|
|
9
12
|
import './crud.mjs';
|
|
10
|
-
import 'yup';
|
|
11
13
|
import './utils/types.mjs';
|
|
12
14
|
import './utils/strings.mjs';
|
|
13
15
|
import './interface/crud/emails.mjs';
|
|
@@ -17,7 +19,6 @@ import './interface/crud/projects.mjs';
|
|
|
17
19
|
import './interface/crud/svix-token.mjs';
|
|
18
20
|
import './interface/crud/team-permissions.mjs';
|
|
19
21
|
import './interface/crud/transactions.mjs';
|
|
20
|
-
import './utils/dates.mjs';
|
|
21
22
|
import './utils/errors.mjs';
|
|
22
23
|
import './utils/json.mjs';
|
|
23
24
|
import './interface/crud/connected-accounts.mjs';
|
|
@@ -32,7 +33,5 @@ import './interface/crud/team-member-profiles.mjs';
|
|
|
32
33
|
import './interface/crud/team-memberships.mjs';
|
|
33
34
|
import './interface/crud/teams.mjs';
|
|
34
35
|
import './interface/crud/users.mjs';
|
|
35
|
-
import './schema-fields.mjs';
|
|
36
|
-
import './utils/currency-constants.mjs';
|
|
37
36
|
import '@simplewebauthn/types';
|
|
38
37
|
import './interface/crud/project-api-keys.mjs';
|
package/dist/index.d.ts
CHANGED
|
@@ -3,11 +3,13 @@ export { StackClientInterface } from './interface/client-interface.js';
|
|
|
3
3
|
export { StackServerInterface } from './interface/server-interface.js';
|
|
4
4
|
export { KnownError, KnownErrors } from './known-errors.js';
|
|
5
5
|
import './sessions.js';
|
|
6
|
-
import '
|
|
6
|
+
import 'yup';
|
|
7
|
+
import './schema-fields.js';
|
|
8
|
+
import './utils/currency-constants.js';
|
|
9
|
+
import './utils/dates.js';
|
|
7
10
|
import './utils/results.js';
|
|
8
11
|
import './interface/crud/config.js';
|
|
9
12
|
import './crud.js';
|
|
10
|
-
import 'yup';
|
|
11
13
|
import './utils/types.js';
|
|
12
14
|
import './utils/strings.js';
|
|
13
15
|
import './interface/crud/emails.js';
|
|
@@ -17,7 +19,6 @@ import './interface/crud/projects.js';
|
|
|
17
19
|
import './interface/crud/svix-token.js';
|
|
18
20
|
import './interface/crud/team-permissions.js';
|
|
19
21
|
import './interface/crud/transactions.js';
|
|
20
|
-
import './utils/dates.js';
|
|
21
22
|
import './utils/errors.js';
|
|
22
23
|
import './utils/json.js';
|
|
23
24
|
import './interface/crud/connected-accounts.js';
|
|
@@ -32,7 +33,5 @@ import './interface/crud/team-member-profiles.js';
|
|
|
32
33
|
import './interface/crud/team-memberships.js';
|
|
33
34
|
import './interface/crud/teams.js';
|
|
34
35
|
import './interface/crud/users.js';
|
|
35
|
-
import './schema-fields.js';
|
|
36
|
-
import './utils/currency-constants.js';
|
|
37
36
|
import '@simplewebauthn/types';
|
|
38
37
|
import './interface/crud/project-api-keys.js';
|
|
@@ -13,12 +13,13 @@ import { ServerAuthApplicationOptions, StackServerInterface } from './server-int
|
|
|
13
13
|
import './client-interface.mjs';
|
|
14
14
|
import '../utils/errors.mjs';
|
|
15
15
|
import '../utils/json.mjs';
|
|
16
|
-
import 'jose';
|
|
17
|
-
import '../crud.mjs';
|
|
18
16
|
import 'yup';
|
|
17
|
+
import '../schema-fields.mjs';
|
|
18
|
+
import '../utils/currency-constants.mjs';
|
|
19
|
+
import '../utils/dates.mjs';
|
|
20
|
+
import '../crud.mjs';
|
|
19
21
|
import '../utils/types.mjs';
|
|
20
22
|
import '../utils/strings.mjs';
|
|
21
|
-
import '../utils/dates.mjs';
|
|
22
23
|
import './crud/connected-accounts.mjs';
|
|
23
24
|
import './crud/contact-channels.mjs';
|
|
24
25
|
import './crud/current-user.mjs';
|
|
@@ -31,8 +32,6 @@ import './crud/team-member-profiles.mjs';
|
|
|
31
32
|
import './crud/team-memberships.mjs';
|
|
32
33
|
import './crud/teams.mjs';
|
|
33
34
|
import './crud/users.mjs';
|
|
34
|
-
import '../schema-fields.mjs';
|
|
35
|
-
import '../utils/currency-constants.mjs';
|
|
36
35
|
import '@simplewebauthn/types';
|
|
37
36
|
import './crud/project-api-keys.mjs';
|
|
38
37
|
|
|
@@ -13,12 +13,13 @@ import { ServerAuthApplicationOptions, StackServerInterface } from './server-int
|
|
|
13
13
|
import './client-interface.js';
|
|
14
14
|
import '../utils/errors.js';
|
|
15
15
|
import '../utils/json.js';
|
|
16
|
-
import 'jose';
|
|
17
|
-
import '../crud.js';
|
|
18
16
|
import 'yup';
|
|
17
|
+
import '../schema-fields.js';
|
|
18
|
+
import '../utils/currency-constants.js';
|
|
19
|
+
import '../utils/dates.js';
|
|
20
|
+
import '../crud.js';
|
|
19
21
|
import '../utils/types.js';
|
|
20
22
|
import '../utils/strings.js';
|
|
21
|
-
import '../utils/dates.js';
|
|
22
23
|
import './crud/connected-accounts.js';
|
|
23
24
|
import './crud/contact-channels.js';
|
|
24
25
|
import './crud/current-user.js';
|
|
@@ -31,8 +32,6 @@ import './crud/team-member-profiles.js';
|
|
|
31
32
|
import './crud/team-memberships.js';
|
|
32
33
|
import './crud/teams.js';
|
|
33
34
|
import './crud/users.js';
|
|
34
|
-
import '../schema-fields.js';
|
|
35
|
-
import '../utils/currency-constants.js';
|
|
36
35
|
import '@simplewebauthn/types';
|
|
37
36
|
import './crud/project-api-keys.js';
|
|
38
37
|
|
|
@@ -22,7 +22,6 @@ import { TeamsCrud } from './crud/teams.mjs';
|
|
|
22
22
|
import '../utils/errors.mjs';
|
|
23
23
|
import '../utils/currency-constants.mjs';
|
|
24
24
|
import '../utils/dates.mjs';
|
|
25
|
-
import 'jose';
|
|
26
25
|
import '../crud.mjs';
|
|
27
26
|
import '../utils/types.mjs';
|
|
28
27
|
import '../utils/strings.mjs';
|
|
@@ -171,7 +171,7 @@ var StackClientInterface = class {
|
|
|
171
171
|
if (!result.access_token) {
|
|
172
172
|
throw new import_errors.StackAssertionError("Access token not found in token endpoint response, this is weird!");
|
|
173
173
|
}
|
|
174
|
-
return
|
|
174
|
+
return import_sessions.AccessToken.createIfValid(result.access_token) ?? (0, import_errors.throwErr)("Access token in fetchNewAccessToken is invalid, looks like the backend is returning an invalid token!", { result });
|
|
175
175
|
}
|
|
176
176
|
async sendClientRequest(path, requestOptions, session, requestType = "client") {
|
|
177
177
|
session ??= this.createSession({
|