@oursprivacy/platform-sdk 1.11.0 → 1.13.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 +24 -0
- package/README.md +31 -0
- package/client.d.mts +32 -14
- package/client.d.mts.map +1 -1
- package/client.d.ts +32 -14
- package/client.d.ts.map +1 -1
- package/client.js +26 -4
- package/client.js.map +1 -1
- package/client.mjs +26 -4
- package/client.mjs.map +1 -1
- package/core/pagination.d.mts +60 -0
- package/core/pagination.d.mts.map +1 -0
- package/core/pagination.d.ts +60 -0
- package/core/pagination.d.ts.map +1 -0
- package/core/pagination.js +101 -0
- package/core/pagination.js.map +1 -0
- package/core/pagination.mjs +95 -0
- package/core/pagination.mjs.map +1 -0
- package/index.d.mts +1 -0
- package/index.d.mts.map +1 -1
- package/index.d.ts +1 -0
- package/index.d.ts.map +1 -1
- package/index.js +3 -1
- package/index.js.map +1 -1
- package/index.mjs +1 -0
- package/index.mjs.map +1 -1
- package/package.json +11 -1
- package/pagination.d.mts +2 -0
- package/pagination.d.mts.map +1 -0
- package/pagination.d.ts +2 -0
- package/pagination.d.ts.map +1 -0
- package/pagination.js +6 -0
- package/pagination.js.map +1 -0
- package/pagination.mjs +2 -0
- package/pagination.mjs.map +1 -0
- package/resources/allowed-events.d.mts +18 -18
- package/resources/allowed-events.d.mts.map +1 -1
- package/resources/allowed-events.d.ts +18 -18
- package/resources/allowed-events.d.ts.map +1 -1
- package/resources/allowed-events.js +7 -7
- package/resources/allowed-events.js.map +1 -1
- package/resources/allowed-events.mjs +7 -7
- package/resources/allowed-events.mjs.map +1 -1
- package/resources/consent-settings.d.mts +2568 -124
- package/resources/consent-settings.d.mts.map +1 -1
- package/resources/consent-settings.d.ts +2568 -124
- package/resources/consent-settings.d.ts.map +1 -1
- package/resources/consent-settings.js +24 -7
- package/resources/consent-settings.js.map +1 -1
- package/resources/consent-settings.mjs +24 -7
- package/resources/consent-settings.mjs.map +1 -1
- package/resources/destinations.d.mts +33 -32
- package/resources/destinations.d.mts.map +1 -1
- package/resources/destinations.d.ts +33 -32
- package/resources/destinations.d.ts.map +1 -1
- package/resources/destinations.js +8 -7
- package/resources/destinations.js.map +1 -1
- package/resources/destinations.mjs +8 -7
- package/resources/destinations.mjs.map +1 -1
- package/resources/experiment-settings.d.mts +277 -0
- package/resources/experiment-settings.d.mts.map +1 -0
- package/resources/experiment-settings.d.ts +277 -0
- package/resources/experiment-settings.d.ts.map +1 -0
- package/resources/experiment-settings.js +77 -0
- package/resources/experiment-settings.js.map +1 -0
- package/resources/experiment-settings.mjs +73 -0
- package/resources/experiment-settings.mjs.map +1 -0
- package/resources/experiment-variants.d.mts +659 -0
- package/resources/experiment-variants.d.mts.map +1 -0
- package/resources/experiment-variants.d.ts +659 -0
- package/resources/experiment-variants.d.ts.map +1 -0
- package/resources/experiment-variants.js +79 -0
- package/resources/experiment-variants.js.map +1 -0
- package/resources/experiment-variants.mjs +75 -0
- package/resources/experiment-variants.mjs.map +1 -0
- package/resources/experiments.d.mts +2002 -0
- package/resources/experiments.d.mts.map +1 -0
- package/resources/experiments.d.ts +2002 -0
- package/resources/experiments.d.ts.map +1 -0
- package/resources/experiments.js +166 -0
- package/resources/experiments.js.map +1 -0
- package/resources/experiments.mjs +162 -0
- package/resources/experiments.mjs.map +1 -0
- package/resources/global-dispatch-centers.d.mts +125 -58
- package/resources/global-dispatch-centers.d.mts.map +1 -1
- package/resources/global-dispatch-centers.d.ts +125 -58
- package/resources/global-dispatch-centers.d.ts.map +1 -1
- package/resources/global-dispatch-centers.js +10 -7
- package/resources/global-dispatch-centers.js.map +1 -1
- package/resources/global-dispatch-centers.mjs +10 -7
- package/resources/global-dispatch-centers.mjs.map +1 -1
- package/resources/index.d.mts +11 -7
- package/resources/index.d.mts.map +1 -1
- package/resources/index.d.ts +11 -7
- package/resources/index.d.ts.map +1 -1
- package/resources/index.js +9 -1
- package/resources/index.js.map +1 -1
- package/resources/index.mjs +4 -0
- package/resources/index.mjs.map +1 -1
- package/resources/mappings.d.mts +136 -0
- package/resources/mappings.d.mts.map +1 -0
- package/resources/mappings.d.ts +136 -0
- package/resources/mappings.d.ts.map +1 -0
- package/resources/mappings.js +41 -0
- package/resources/mappings.js.map +1 -0
- package/resources/mappings.mjs +37 -0
- package/resources/mappings.mjs.map +1 -0
- package/resources/replay-settings.d.mts +123 -24
- package/resources/replay-settings.d.mts.map +1 -1
- package/resources/replay-settings.d.ts +123 -24
- package/resources/replay-settings.d.ts.map +1 -1
- package/resources/replay-settings.js +24 -10
- package/resources/replay-settings.js.map +1 -1
- package/resources/replay-settings.mjs +24 -10
- package/resources/replay-settings.mjs.map +1 -1
- package/resources/sources.d.mts +64 -27
- package/resources/sources.d.mts.map +1 -1
- package/resources/sources.d.ts +64 -27
- package/resources/sources.d.ts.map +1 -1
- package/resources/sources.js +14 -7
- package/resources/sources.js.map +1 -1
- package/resources/sources.mjs +14 -7
- package/resources/sources.mjs.map +1 -1
- package/resources/versions.d.mts +742 -16
- package/resources/versions.d.mts.map +1 -1
- package/resources/versions.d.ts +742 -16
- package/resources/versions.d.ts.map +1 -1
- package/resources/versions.js +45 -5
- package/resources/versions.js.map +1 -1
- package/resources/versions.mjs +45 -5
- package/resources/versions.mjs.map +1 -1
- package/src/client.ts +206 -29
- package/src/core/pagination.ts +165 -0
- package/src/index.ts +1 -0
- package/src/pagination.ts +2 -0
- package/src/resources/allowed-events.ts +27 -27
- package/src/resources/consent-settings.ts +3036 -244
- package/src/resources/destinations.ts +128 -127
- package/src/resources/experiment-settings.ts +367 -0
- package/src/resources/experiment-variants.ts +870 -0
- package/src/resources/experiments.ts +2446 -0
- package/src/resources/global-dispatch-centers.ts +155 -65
- package/src/resources/index.ts +75 -7
- package/src/resources/mappings.ts +230 -0
- package/src/resources/replay-settings.ts +142 -35
- package/src/resources/sources.ts +116 -71
- package/src/resources/versions.ts +1130 -17
- package/src/version.ts +1 -1
- package/version.d.mts +1 -1
- package/version.d.ts +1 -1
- package/version.js +1 -1
- package/version.mjs +1 -1
|
@@ -0,0 +1,165 @@
|
|
|
1
|
+
// File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details.
|
|
2
|
+
|
|
3
|
+
import { OursPrivacyPlatformError } from './error';
|
|
4
|
+
import { FinalRequestOptions } from '../internal/request-options';
|
|
5
|
+
import { defaultParseResponse } from '../internal/parse';
|
|
6
|
+
import { type OursPrivacyPlatform } from '../client';
|
|
7
|
+
import { APIPromise } from './api-promise';
|
|
8
|
+
import { type APIResponseProps } from '../internal/parse';
|
|
9
|
+
import { maybeObj } from '../internal/utils/values';
|
|
10
|
+
|
|
11
|
+
export type PageRequestOptions = Pick<FinalRequestOptions, 'query' | 'headers' | 'body' | 'path' | 'method'>;
|
|
12
|
+
|
|
13
|
+
export abstract class AbstractPage<Item> implements AsyncIterable<Item> {
|
|
14
|
+
#client: OursPrivacyPlatform;
|
|
15
|
+
protected options: FinalRequestOptions;
|
|
16
|
+
|
|
17
|
+
protected response: Response;
|
|
18
|
+
protected body: unknown;
|
|
19
|
+
|
|
20
|
+
constructor(client: OursPrivacyPlatform, response: Response, body: unknown, options: FinalRequestOptions) {
|
|
21
|
+
this.#client = client;
|
|
22
|
+
this.options = options;
|
|
23
|
+
this.response = response;
|
|
24
|
+
this.body = body;
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
abstract nextPageRequestOptions(): PageRequestOptions | null;
|
|
28
|
+
|
|
29
|
+
abstract getPaginatedItems(): Item[];
|
|
30
|
+
|
|
31
|
+
hasNextPage(): boolean {
|
|
32
|
+
const items = this.getPaginatedItems();
|
|
33
|
+
if (!items.length) return false;
|
|
34
|
+
return this.nextPageRequestOptions() != null;
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
async getNextPage(): Promise<this> {
|
|
38
|
+
const nextOptions = this.nextPageRequestOptions();
|
|
39
|
+
if (!nextOptions) {
|
|
40
|
+
throw new OursPrivacyPlatformError(
|
|
41
|
+
'No next page expected; please check `.hasNextPage()` before calling `.getNextPage()`.',
|
|
42
|
+
);
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
return await this.#client.requestAPIList(this.constructor as any, nextOptions);
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
async *iterPages(): AsyncGenerator<this> {
|
|
49
|
+
let page: this = this;
|
|
50
|
+
yield page;
|
|
51
|
+
while (page.hasNextPage()) {
|
|
52
|
+
page = await page.getNextPage();
|
|
53
|
+
yield page;
|
|
54
|
+
}
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
async *[Symbol.asyncIterator](): AsyncGenerator<Item> {
|
|
58
|
+
for await (const page of this.iterPages()) {
|
|
59
|
+
for (const item of page.getPaginatedItems()) {
|
|
60
|
+
yield item;
|
|
61
|
+
}
|
|
62
|
+
}
|
|
63
|
+
}
|
|
64
|
+
}
|
|
65
|
+
|
|
66
|
+
/**
|
|
67
|
+
* This subclass of Promise will resolve to an instantiated Page once the request completes.
|
|
68
|
+
*
|
|
69
|
+
* It also implements AsyncIterable to allow auto-paginating iteration on an unawaited list call, eg:
|
|
70
|
+
*
|
|
71
|
+
* for await (const item of client.items.list()) {
|
|
72
|
+
* console.log(item)
|
|
73
|
+
* }
|
|
74
|
+
*/
|
|
75
|
+
export class PagePromise<
|
|
76
|
+
PageClass extends AbstractPage<Item>,
|
|
77
|
+
Item = ReturnType<PageClass['getPaginatedItems']>[number],
|
|
78
|
+
>
|
|
79
|
+
extends APIPromise<PageClass>
|
|
80
|
+
implements AsyncIterable<Item>
|
|
81
|
+
{
|
|
82
|
+
constructor(
|
|
83
|
+
client: OursPrivacyPlatform,
|
|
84
|
+
request: Promise<APIResponseProps>,
|
|
85
|
+
Page: new (...args: ConstructorParameters<typeof AbstractPage>) => PageClass,
|
|
86
|
+
) {
|
|
87
|
+
super(
|
|
88
|
+
client,
|
|
89
|
+
request,
|
|
90
|
+
async (client, props) =>
|
|
91
|
+
new Page(client, props.response, await defaultParseResponse(client, props), props.options),
|
|
92
|
+
);
|
|
93
|
+
}
|
|
94
|
+
|
|
95
|
+
/**
|
|
96
|
+
* Allow auto-paginating iteration on an unawaited list call, eg:
|
|
97
|
+
*
|
|
98
|
+
* for await (const item of client.items.list()) {
|
|
99
|
+
* console.log(item)
|
|
100
|
+
* }
|
|
101
|
+
*/
|
|
102
|
+
async *[Symbol.asyncIterator](): AsyncGenerator<Item> {
|
|
103
|
+
const page = await this;
|
|
104
|
+
for await (const item of page) {
|
|
105
|
+
yield item;
|
|
106
|
+
}
|
|
107
|
+
}
|
|
108
|
+
}
|
|
109
|
+
|
|
110
|
+
export interface CursorResponse<Item> {
|
|
111
|
+
entities: Array<Item>;
|
|
112
|
+
|
|
113
|
+
pagination: CursorResponse.Pagination;
|
|
114
|
+
}
|
|
115
|
+
|
|
116
|
+
export namespace CursorResponse {
|
|
117
|
+
export interface Pagination {
|
|
118
|
+
hasMore?: boolean;
|
|
119
|
+
|
|
120
|
+
nextCursor?: string | null;
|
|
121
|
+
}
|
|
122
|
+
}
|
|
123
|
+
|
|
124
|
+
export interface CursorParams {
|
|
125
|
+
cursor?: string;
|
|
126
|
+
|
|
127
|
+
limit?: number;
|
|
128
|
+
}
|
|
129
|
+
|
|
130
|
+
export class Cursor<Item> extends AbstractPage<Item> implements CursorResponse<Item> {
|
|
131
|
+
entities: Array<Item>;
|
|
132
|
+
|
|
133
|
+
pagination: CursorResponse.Pagination;
|
|
134
|
+
|
|
135
|
+
constructor(
|
|
136
|
+
client: OursPrivacyPlatform,
|
|
137
|
+
response: Response,
|
|
138
|
+
body: CursorResponse<Item>,
|
|
139
|
+
options: FinalRequestOptions,
|
|
140
|
+
) {
|
|
141
|
+
super(client, response, body, options);
|
|
142
|
+
|
|
143
|
+
this.entities = body.entities || [];
|
|
144
|
+
this.pagination = body.pagination || {};
|
|
145
|
+
}
|
|
146
|
+
|
|
147
|
+
getPaginatedItems(): Item[] {
|
|
148
|
+
return this.entities ?? [];
|
|
149
|
+
}
|
|
150
|
+
|
|
151
|
+
nextPageRequestOptions(): PageRequestOptions | null {
|
|
152
|
+
const cursor = this.pagination?.nextCursor;
|
|
153
|
+
if (!cursor) {
|
|
154
|
+
return null;
|
|
155
|
+
}
|
|
156
|
+
|
|
157
|
+
return {
|
|
158
|
+
...this.options,
|
|
159
|
+
query: {
|
|
160
|
+
...maybeObj(this.options.query),
|
|
161
|
+
cursor,
|
|
162
|
+
},
|
|
163
|
+
};
|
|
164
|
+
}
|
|
165
|
+
}
|
package/src/index.ts
CHANGED
|
@@ -5,6 +5,7 @@ export { OursPrivacyPlatform as default } from './client';
|
|
|
5
5
|
export { type Uploadable, toFile } from './core/uploads';
|
|
6
6
|
export { APIPromise } from './core/api-promise';
|
|
7
7
|
export { OursPrivacyPlatform, type ClientOptions } from './client';
|
|
8
|
+
export { PagePromise } from './core/pagination';
|
|
8
9
|
export {
|
|
9
10
|
OursPrivacyPlatformError,
|
|
10
11
|
APIError,
|
|
@@ -6,6 +6,13 @@ import { RequestOptions } from '../internal/request-options';
|
|
|
6
6
|
import { path } from '../internal/utils/path';
|
|
7
7
|
|
|
8
8
|
export class AllowedEvents extends APIResource {
|
|
9
|
+
/**
|
|
10
|
+
* List all allowed events. Requires scope: allowedEvent:list
|
|
11
|
+
*/
|
|
12
|
+
list(options?: RequestOptions): APIPromise<AllowedEventListResponse> {
|
|
13
|
+
return this._client.get('/rest/v1/allowed-events', options);
|
|
14
|
+
}
|
|
15
|
+
|
|
9
16
|
/**
|
|
10
17
|
* Create a new allowed event. Requires scope: allowedEvent:create
|
|
11
18
|
*/
|
|
@@ -21,20 +28,31 @@ export class AllowedEvents extends APIResource {
|
|
|
21
28
|
}
|
|
22
29
|
|
|
23
30
|
/**
|
|
24
|
-
*
|
|
25
|
-
*/
|
|
26
|
-
list(options?: RequestOptions): APIPromise<AllowedEventListResponse> {
|
|
27
|
-
return this._client.get('/rest/v1/allowed-events', options);
|
|
28
|
-
}
|
|
29
|
-
|
|
30
|
-
/**
|
|
31
|
-
* Delete a allowed event. Requires scope: allowedEvent:delete
|
|
31
|
+
* Delete an allowed event. Requires scope: allowedEvent:delete
|
|
32
32
|
*/
|
|
33
33
|
delete(id: string, options?: RequestOptions): APIPromise<AllowedEventDeleteResponse> {
|
|
34
34
|
return this._client.delete(path`/rest/v1/allowed-events/${id}`, options);
|
|
35
35
|
}
|
|
36
36
|
}
|
|
37
37
|
|
|
38
|
+
export interface AllowedEventListResponse {
|
|
39
|
+
entities: Array<AllowedEventListResponse.Entity>;
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
export namespace AllowedEventListResponse {
|
|
43
|
+
export interface Entity {
|
|
44
|
+
id: string;
|
|
45
|
+
|
|
46
|
+
createdAt: string;
|
|
47
|
+
|
|
48
|
+
destinationIds: Array<string>;
|
|
49
|
+
|
|
50
|
+
name: string;
|
|
51
|
+
|
|
52
|
+
updatedAt?: string | null;
|
|
53
|
+
}
|
|
54
|
+
}
|
|
55
|
+
|
|
38
56
|
export interface AllowedEventCreateResponse {
|
|
39
57
|
id: string;
|
|
40
58
|
|
|
@@ -59,24 +77,6 @@ export interface AllowedEventRetrieveResponse {
|
|
|
59
77
|
updatedAt?: string | null;
|
|
60
78
|
}
|
|
61
79
|
|
|
62
|
-
export interface AllowedEventListResponse {
|
|
63
|
-
entities: Array<AllowedEventListResponse.Entity>;
|
|
64
|
-
}
|
|
65
|
-
|
|
66
|
-
export namespace AllowedEventListResponse {
|
|
67
|
-
export interface Entity {
|
|
68
|
-
id: string;
|
|
69
|
-
|
|
70
|
-
createdAt: string;
|
|
71
|
-
|
|
72
|
-
destinationIds: Array<string>;
|
|
73
|
-
|
|
74
|
-
name: string;
|
|
75
|
-
|
|
76
|
-
updatedAt?: string | null;
|
|
77
|
-
}
|
|
78
|
-
}
|
|
79
|
-
|
|
80
80
|
export type AllowedEventDeleteResponse = boolean;
|
|
81
81
|
|
|
82
82
|
export interface AllowedEventCreateParams {
|
|
@@ -87,9 +87,9 @@ export interface AllowedEventCreateParams {
|
|
|
87
87
|
|
|
88
88
|
export declare namespace AllowedEvents {
|
|
89
89
|
export {
|
|
90
|
+
type AllowedEventListResponse as AllowedEventListResponse,
|
|
90
91
|
type AllowedEventCreateResponse as AllowedEventCreateResponse,
|
|
91
92
|
type AllowedEventRetrieveResponse as AllowedEventRetrieveResponse,
|
|
92
|
-
type AllowedEventListResponse as AllowedEventListResponse,
|
|
93
93
|
type AllowedEventDeleteResponse as AllowedEventDeleteResponse,
|
|
94
94
|
type AllowedEventCreateParams as AllowedEventCreateParams,
|
|
95
95
|
};
|