@postrun/js 3.1.0 → 3.2.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/dist/{chunk-BJ6NXBN5.js → chunk-A6DM6I6G.js} +64 -3
- package/dist/chunk-A6DM6I6G.js.map +1 -0
- package/dist/{chunk-DT4DW5LA.js → chunk-PE3ULG66.js} +87 -5
- package/dist/chunk-PE3ULG66.js.map +1 -0
- package/dist/index.cjs +174 -1
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +39 -3
- package/dist/index.d.ts +39 -3
- package/dist/index.js +32 -4
- package/dist/index.js.map +1 -1
- package/dist/query.cjs +62 -0
- package/dist/query.cjs.map +1 -1
- package/dist/query.d.cts +550 -1
- package/dist/query.d.ts +550 -1
- package/dist/query.js +61 -1
- package/dist/query.js.map +1 -1
- package/dist/schemas/index.cjs +69 -0
- package/dist/schemas/index.cjs.map +1 -1
- package/dist/schemas/index.d.cts +83 -1
- package/dist/schemas/index.d.ts +83 -1
- package/dist/schemas/index.js +2 -2
- package/dist/server.cjs +108 -1
- package/dist/server.cjs.map +1 -1
- package/dist/server.d.cts +1 -1
- package/dist/server.d.ts +1 -1
- package/dist/server.js +2 -2
- package/dist/{types.gen-MxJw6FpT.d.cts → types.gen-K4cuIpk3.d.cts} +529 -6
- package/dist/{types.gen-MxJw6FpT.d.ts → types.gen-K4cuIpk3.d.ts} +529 -6
- package/package.json +2 -1
- package/dist/chunk-BJ6NXBN5.js.map +0 -1
- package/dist/chunk-DT4DW5LA.js.map +0 -1
package/dist/index.cjs
CHANGED
|
@@ -3,6 +3,7 @@
|
|
|
3
3
|
var z = require('zod');
|
|
4
4
|
var Uppy = require('@uppy/core');
|
|
5
5
|
var AwsS3 = require('@uppy/aws-s3');
|
|
6
|
+
var pWaitFor = require('p-wait-for');
|
|
6
7
|
|
|
7
8
|
function _interopDefault (e) { return e && e.__esModule ? e : { default: e }; }
|
|
8
9
|
|
|
@@ -27,6 +28,7 @@ function _interopNamespace(e) {
|
|
|
27
28
|
var z__namespace = /*#__PURE__*/_interopNamespace(z);
|
|
28
29
|
var Uppy__default = /*#__PURE__*/_interopDefault(Uppy);
|
|
29
30
|
var AwsS3__default = /*#__PURE__*/_interopDefault(AwsS3);
|
|
31
|
+
var pWaitFor__default = /*#__PURE__*/_interopDefault(pWaitFor);
|
|
30
32
|
|
|
31
33
|
// src/client/core/bodySerializer.gen.ts
|
|
32
34
|
var jsonBodySerializer = {
|
|
@@ -4839,6 +4841,8 @@ z__namespace.object({
|
|
|
4839
4841
|
"ONE_PER_CLICK",
|
|
4840
4842
|
"MANY_PER_CLICK"
|
|
4841
4843
|
]),
|
|
4844
|
+
click_through_lookback_window_days: z__namespace.number().nullable(),
|
|
4845
|
+
view_through_lookback_window_days: z__namespace.number().nullable(),
|
|
4842
4846
|
value_settings: z__namespace.object({
|
|
4843
4847
|
default_value: z__namespace.number().nullable(),
|
|
4844
4848
|
default_currency_code: z__namespace.string().nullable(),
|
|
@@ -5018,6 +5022,8 @@ z__namespace.object({
|
|
|
5018
5022
|
"ONE_PER_CLICK",
|
|
5019
5023
|
"MANY_PER_CLICK"
|
|
5020
5024
|
]),
|
|
5025
|
+
click_through_lookback_window_days: z__namespace.number().nullable(),
|
|
5026
|
+
view_through_lookback_window_days: z__namespace.number().nullable(),
|
|
5021
5027
|
value_settings: z__namespace.object({
|
|
5022
5028
|
default_value: z__namespace.number().nullable(),
|
|
5023
5029
|
default_currency_code: z__namespace.string().nullable(),
|
|
@@ -5042,6 +5048,61 @@ z__namespace.object({
|
|
|
5042
5048
|
event_snippet: z__namespace.string().nullable()
|
|
5043
5049
|
}))
|
|
5044
5050
|
});
|
|
5051
|
+
z__namespace.object({
|
|
5052
|
+
name: z__namespace.string().min(1).max(255).optional(),
|
|
5053
|
+
category: z__namespace.enum([
|
|
5054
|
+
"DEFAULT",
|
|
5055
|
+
"PAGE_VIEW",
|
|
5056
|
+
"PURCHASE",
|
|
5057
|
+
"SIGNUP",
|
|
5058
|
+
"DOWNLOAD",
|
|
5059
|
+
"ADD_TO_CART",
|
|
5060
|
+
"BEGIN_CHECKOUT",
|
|
5061
|
+
"SUBSCRIBE_PAID",
|
|
5062
|
+
"PHONE_CALL_LEAD",
|
|
5063
|
+
"IMPORTED_LEAD",
|
|
5064
|
+
"SUBMIT_LEAD_FORM",
|
|
5065
|
+
"BOOK_APPOINTMENT",
|
|
5066
|
+
"REQUEST_QUOTE",
|
|
5067
|
+
"GET_DIRECTIONS",
|
|
5068
|
+
"OUTBOUND_CLICK",
|
|
5069
|
+
"CONTACT",
|
|
5070
|
+
"ENGAGEMENT",
|
|
5071
|
+
"STORE_VISIT",
|
|
5072
|
+
"STORE_SALE",
|
|
5073
|
+
"QUALIFIED_LEAD",
|
|
5074
|
+
"CONVERTED_LEAD",
|
|
5075
|
+
"YOUTUBE_FOLLOW_ON_VIEWS"
|
|
5076
|
+
]).optional(),
|
|
5077
|
+
status: z__namespace.enum(["ENABLED"]).optional(),
|
|
5078
|
+
value_settings: z__namespace.object({
|
|
5079
|
+
default_value: z__namespace.number().gte(0).optional(),
|
|
5080
|
+
default_currency_code: z__namespace.string().length(3).optional(),
|
|
5081
|
+
always_use_default_value: z__namespace.boolean().optional()
|
|
5082
|
+
}).optional(),
|
|
5083
|
+
counting_type: z__namespace.enum(["ONE_PER_CLICK", "MANY_PER_CLICK"]).optional(),
|
|
5084
|
+
click_through_lookback_window_days: z__namespace.int().gt(0).lte(9007199254740991).optional(),
|
|
5085
|
+
view_through_lookback_window_days: z__namespace.int().gt(0).lte(9007199254740991).optional(),
|
|
5086
|
+
primary_for_goal: z__namespace.boolean().optional(),
|
|
5087
|
+
dry_run: z__namespace.boolean().optional().default(false)
|
|
5088
|
+
});
|
|
5089
|
+
z__namespace.object({
|
|
5090
|
+
"Idempotency-Key": z__namespace.string().min(1).max(255).optional()
|
|
5091
|
+
});
|
|
5092
|
+
z__namespace.object({
|
|
5093
|
+
connection_id: z__namespace.string(),
|
|
5094
|
+
id: z__namespace.string().regex(/^\d+$/)
|
|
5095
|
+
});
|
|
5096
|
+
z__namespace.object({
|
|
5097
|
+
dry_run: z__namespace.boolean().optional().default(false)
|
|
5098
|
+
});
|
|
5099
|
+
z__namespace.object({
|
|
5100
|
+
"Idempotency-Key": z__namespace.string().min(1).max(255).optional()
|
|
5101
|
+
});
|
|
5102
|
+
z__namespace.object({
|
|
5103
|
+
connection_id: z__namespace.string(),
|
|
5104
|
+
id: z__namespace.string().regex(/^\d+$/)
|
|
5105
|
+
});
|
|
5045
5106
|
z__namespace.object({
|
|
5046
5107
|
conversion_action_id: z__namespace.string().regex(/^\d+$/),
|
|
5047
5108
|
conversions: z__namespace.array(zGoogleAdsConversionEvent).min(1).max(2e3),
|
|
@@ -6088,8 +6149,54 @@ var PostrunError = class extends Error {
|
|
|
6088
6149
|
}
|
|
6089
6150
|
};
|
|
6090
6151
|
|
|
6152
|
+
// src/token-cache.ts
|
|
6153
|
+
function createTokenCache(getToken) {
|
|
6154
|
+
let cached;
|
|
6155
|
+
let inFlight;
|
|
6156
|
+
const mint = () => {
|
|
6157
|
+
if (!inFlight) {
|
|
6158
|
+
inFlight = Promise.resolve().then(getToken).then((token) => {
|
|
6159
|
+
cached = token;
|
|
6160
|
+
return token;
|
|
6161
|
+
}).finally(() => {
|
|
6162
|
+
inFlight = void 0;
|
|
6163
|
+
});
|
|
6164
|
+
}
|
|
6165
|
+
return inFlight;
|
|
6166
|
+
};
|
|
6167
|
+
return {
|
|
6168
|
+
current() {
|
|
6169
|
+
return cached !== void 0 ? Promise.resolve(cached) : mint();
|
|
6170
|
+
},
|
|
6171
|
+
refresh() {
|
|
6172
|
+
cached = void 0;
|
|
6173
|
+
return mint();
|
|
6174
|
+
}
|
|
6175
|
+
};
|
|
6176
|
+
}
|
|
6177
|
+
|
|
6091
6178
|
// src/client.ts
|
|
6092
6179
|
var DEFAULT_BASE_URL = "https://api.postrun.ai/v1";
|
|
6180
|
+
var UNAUTHORIZED = 401;
|
|
6181
|
+
function createRetryingFetch(tokenCache) {
|
|
6182
|
+
const realFetch = (...args) => globalThis.fetch(...args);
|
|
6183
|
+
return async (input, init) => {
|
|
6184
|
+
const request = new Request(input, init);
|
|
6185
|
+
const retryable = request.clone();
|
|
6186
|
+
const response = await realFetch(request);
|
|
6187
|
+
if (response.status !== UNAUTHORIZED) {
|
|
6188
|
+
return response;
|
|
6189
|
+
}
|
|
6190
|
+
try {
|
|
6191
|
+
const token = await tokenCache.refresh();
|
|
6192
|
+
const headers = new Headers(retryable.headers);
|
|
6193
|
+
headers.set("Authorization", `Bearer ${token}`);
|
|
6194
|
+
return await realFetch(new Request(retryable, { headers }));
|
|
6195
|
+
} catch {
|
|
6196
|
+
return response;
|
|
6197
|
+
}
|
|
6198
|
+
};
|
|
6199
|
+
}
|
|
6093
6200
|
function appendScalar(parts, key, value) {
|
|
6094
6201
|
parts.push(
|
|
6095
6202
|
`${encodeURIComponent(key)}=${encodeURIComponent(String(value))}`
|
|
@@ -6116,10 +6223,12 @@ function serializeQuery(query) {
|
|
|
6116
6223
|
return parts.join("&");
|
|
6117
6224
|
}
|
|
6118
6225
|
function createPostrunClient(options) {
|
|
6226
|
+
const tokenCache = createTokenCache(options.getToken);
|
|
6119
6227
|
const client2 = createClient(
|
|
6120
6228
|
createConfig({
|
|
6121
6229
|
baseUrl: options.baseUrl ?? DEFAULT_BASE_URL,
|
|
6122
|
-
auth: () =>
|
|
6230
|
+
auth: () => tokenCache.current(),
|
|
6231
|
+
fetch: createRetryingFetch(tokenCache),
|
|
6123
6232
|
querySerializer: serializeQuery,
|
|
6124
6233
|
throwOnError: true
|
|
6125
6234
|
})
|
|
@@ -7390,6 +7499,40 @@ var googleGetConversionAction = (options) => (options.client ?? client).get({
|
|
|
7390
7499
|
url: "/google/{connection_id}/conversion-actions/{id}",
|
|
7391
7500
|
...options
|
|
7392
7501
|
});
|
|
7502
|
+
var googleUpdateConversionAction = (options) => (options.client ?? client).patch({
|
|
7503
|
+
security: [{
|
|
7504
|
+
key: "secretKey",
|
|
7505
|
+
scheme: "bearer",
|
|
7506
|
+
type: "http"
|
|
7507
|
+
}, {
|
|
7508
|
+
key: "frontendToken",
|
|
7509
|
+
scheme: "bearer",
|
|
7510
|
+
type: "http"
|
|
7511
|
+
}],
|
|
7512
|
+
url: "/google/{connection_id}/conversion-actions/{id}",
|
|
7513
|
+
...options,
|
|
7514
|
+
headers: {
|
|
7515
|
+
"Content-Type": "application/json",
|
|
7516
|
+
...options.headers
|
|
7517
|
+
}
|
|
7518
|
+
});
|
|
7519
|
+
var googleRemoveConversionAction = (options) => (options.client ?? client).post({
|
|
7520
|
+
security: [{
|
|
7521
|
+
key: "secretKey",
|
|
7522
|
+
scheme: "bearer",
|
|
7523
|
+
type: "http"
|
|
7524
|
+
}, {
|
|
7525
|
+
key: "frontendToken",
|
|
7526
|
+
scheme: "bearer",
|
|
7527
|
+
type: "http"
|
|
7528
|
+
}],
|
|
7529
|
+
url: "/google/{connection_id}/conversion-actions/{id}/remove",
|
|
7530
|
+
...options,
|
|
7531
|
+
headers: {
|
|
7532
|
+
"Content-Type": "application/json",
|
|
7533
|
+
...options.headers
|
|
7534
|
+
}
|
|
7535
|
+
});
|
|
7393
7536
|
var googleSendConversions = (options) => (options.client ?? client).post({
|
|
7394
7537
|
security: [{
|
|
7395
7538
|
key: "secretKey",
|
|
@@ -7718,6 +7861,33 @@ async function uploadFile(file, options) {
|
|
|
7718
7861
|
function fileName(file) {
|
|
7719
7862
|
return file instanceof File ? file.name : "upload";
|
|
7720
7863
|
}
|
|
7864
|
+
var DEFAULT_POLL_INTERVAL_MS = 1500;
|
|
7865
|
+
var DEFAULT_POLL_TIMEOUT_MS = 30 * 60 * 1e3;
|
|
7866
|
+
async function waitForMedia(mediaId, options = {}) {
|
|
7867
|
+
const {
|
|
7868
|
+
client: client2,
|
|
7869
|
+
pollInterval = DEFAULT_POLL_INTERVAL_MS,
|
|
7870
|
+
timeout = DEFAULT_POLL_TIMEOUT_MS,
|
|
7871
|
+
signal,
|
|
7872
|
+
onPoll
|
|
7873
|
+
} = options;
|
|
7874
|
+
let latest;
|
|
7875
|
+
await pWaitFor__default.default(
|
|
7876
|
+
async () => {
|
|
7877
|
+
if (signal?.aborted) {
|
|
7878
|
+
throw new DOMException("Media wait aborted", "AbortError");
|
|
7879
|
+
}
|
|
7880
|
+
latest = (await mediaGet({ client: client2, path: { id: mediaId } })).data;
|
|
7881
|
+
onPoll?.(latest);
|
|
7882
|
+
return latest.status === "ready" || latest.status === "failed";
|
|
7883
|
+
},
|
|
7884
|
+
{ interval: pollInterval, timeout }
|
|
7885
|
+
);
|
|
7886
|
+
if (!latest) {
|
|
7887
|
+
throw new Error("Media polling returned no result.");
|
|
7888
|
+
}
|
|
7889
|
+
return latest;
|
|
7890
|
+
}
|
|
7721
7891
|
|
|
7722
7892
|
// src/tiktok.ts
|
|
7723
7893
|
function tiktokPrivacyLabel(value) {
|
|
@@ -8119,6 +8289,7 @@ exports.googleRemoveAdGroupCriterion = googleRemoveAdGroupCriterion;
|
|
|
8119
8289
|
exports.googleRemoveBudget = googleRemoveBudget;
|
|
8120
8290
|
exports.googleRemoveCampaign = googleRemoveCampaign;
|
|
8121
8291
|
exports.googleRemoveCampaignCriterion = googleRemoveCampaignCriterion;
|
|
8292
|
+
exports.googleRemoveConversionAction = googleRemoveConversionAction;
|
|
8122
8293
|
exports.googleRemoveKeyword = googleRemoveKeyword;
|
|
8123
8294
|
exports.googleRunGaql = googleRunGaql;
|
|
8124
8295
|
exports.googleSearchGeoTargets = googleSearchGeoTargets;
|
|
@@ -8128,6 +8299,7 @@ exports.googleSetCampaignGeoSettings = googleSetCampaignGeoSettings;
|
|
|
8128
8299
|
exports.googleSetCampaignTargetingSetting = googleSetCampaignTargetingSetting;
|
|
8129
8300
|
exports.googleSetConversionGoal = googleSetConversionGoal;
|
|
8130
8301
|
exports.googleSetKeywordBid = googleSetKeywordBid;
|
|
8302
|
+
exports.googleUpdateConversionAction = googleUpdateConversionAction;
|
|
8131
8303
|
exports.googleUploadImageAsset = googleUploadImageAsset;
|
|
8132
8304
|
exports.groupAdTree = groupAdTree;
|
|
8133
8305
|
exports.interactionRows = interactionRows;
|
|
@@ -8177,6 +8349,7 @@ exports.tiktokSettings = tiktokSettings;
|
|
|
8177
8349
|
exports.toggleInteraction = toggleInteraction;
|
|
8178
8350
|
exports.tokensMint = tokensMint;
|
|
8179
8351
|
exports.uploadFile = uploadFile;
|
|
8352
|
+
exports.waitForMedia = waitForMedia;
|
|
8180
8353
|
exports.webhooksCreateEndpoint = webhooksCreateEndpoint;
|
|
8181
8354
|
exports.webhooksCreatePortal = webhooksCreatePortal;
|
|
8182
8355
|
exports.webhooksDeleteEndpoint = webhooksDeleteEndpoint;
|