@postrun/js 3.0.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-QXMLASQ6.js → chunk-A6DM6I6G.js} +76 -3
- package/dist/chunk-A6DM6I6G.js.map +1 -0
- package/dist/{chunk-YFAPR4TH.js → chunk-PE3ULG66.js} +87 -5
- package/dist/chunk-PE3ULG66.js.map +1 -0
- package/dist/index.cjs +186 -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 +715 -166
- package/dist/query.d.ts +715 -166
- package/dist/query.js +61 -1
- package/dist/query.js.map +1 -1
- package/dist/schemas/index.cjs +81 -0
- package/dist/schemas/index.cjs.map +1 -1
- package/dist/schemas/index.d.cts +122 -1
- package/dist/schemas/index.d.ts +122 -1
- package/dist/schemas/index.js +2 -2
- package/dist/server.cjs +120 -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-zIKtx009.d.cts → types.gen-K4cuIpk3.d.cts} +547 -24
- package/dist/{types.gen-zIKtx009.d.ts → types.gen-K4cuIpk3.d.ts} +547 -24
- package/package.json +2 -1
- package/dist/chunk-QXMLASQ6.js.map +0 -1
- package/dist/chunk-YFAPR4TH.js.map +0 -1
package/dist/server.cjs
CHANGED
|
@@ -818,6 +818,7 @@ var zErrorCode = z__namespace.enum([
|
|
|
818
818
|
"media_processing",
|
|
819
819
|
"media_upload_init_failed",
|
|
820
820
|
"media_upload_incomplete",
|
|
821
|
+
"media_upload_invalid_parts",
|
|
821
822
|
"not_publishable",
|
|
822
823
|
"invalid_connection",
|
|
823
824
|
"invalid_media",
|
|
@@ -1278,6 +1279,7 @@ var zPostVariant = z__namespace.union([
|
|
|
1278
1279
|
"media_processing",
|
|
1279
1280
|
"media_upload_init_failed",
|
|
1280
1281
|
"media_upload_incomplete",
|
|
1282
|
+
"media_upload_invalid_parts",
|
|
1281
1283
|
"not_publishable",
|
|
1282
1284
|
"invalid_connection",
|
|
1283
1285
|
"invalid_media",
|
|
@@ -1458,6 +1460,7 @@ var zPostVariant = z__namespace.union([
|
|
|
1458
1460
|
"media_processing",
|
|
1459
1461
|
"media_upload_init_failed",
|
|
1460
1462
|
"media_upload_incomplete",
|
|
1463
|
+
"media_upload_invalid_parts",
|
|
1461
1464
|
"not_publishable",
|
|
1462
1465
|
"invalid_connection",
|
|
1463
1466
|
"invalid_media",
|
|
@@ -1622,6 +1625,7 @@ var zPostVariant = z__namespace.union([
|
|
|
1622
1625
|
"media_processing",
|
|
1623
1626
|
"media_upload_init_failed",
|
|
1624
1627
|
"media_upload_incomplete",
|
|
1628
|
+
"media_upload_invalid_parts",
|
|
1625
1629
|
"not_publishable",
|
|
1626
1630
|
"invalid_connection",
|
|
1627
1631
|
"invalid_media",
|
|
@@ -1787,6 +1791,7 @@ var zPostVariant = z__namespace.union([
|
|
|
1787
1791
|
"media_processing",
|
|
1788
1792
|
"media_upload_init_failed",
|
|
1789
1793
|
"media_upload_incomplete",
|
|
1794
|
+
"media_upload_invalid_parts",
|
|
1790
1795
|
"not_publishable",
|
|
1791
1796
|
"invalid_connection",
|
|
1792
1797
|
"invalid_media",
|
|
@@ -1956,6 +1961,7 @@ var zPostVariant = z__namespace.union([
|
|
|
1956
1961
|
"media_processing",
|
|
1957
1962
|
"media_upload_init_failed",
|
|
1958
1963
|
"media_upload_incomplete",
|
|
1964
|
+
"media_upload_invalid_parts",
|
|
1959
1965
|
"not_publishable",
|
|
1960
1966
|
"invalid_connection",
|
|
1961
1967
|
"invalid_media",
|
|
@@ -2969,6 +2975,7 @@ var zGoogleAdsConversionStatusReason = z__namespace.object({
|
|
|
2969
2975
|
"media_processing",
|
|
2970
2976
|
"media_upload_init_failed",
|
|
2971
2977
|
"media_upload_incomplete",
|
|
2978
|
+
"media_upload_invalid_parts",
|
|
2972
2979
|
"not_publishable",
|
|
2973
2980
|
"invalid_connection",
|
|
2974
2981
|
"invalid_media",
|
|
@@ -3634,6 +3641,7 @@ z__namespace.object({
|
|
|
3634
3641
|
"media_processing",
|
|
3635
3642
|
"media_upload_init_failed",
|
|
3636
3643
|
"media_upload_incomplete",
|
|
3644
|
+
"media_upload_invalid_parts",
|
|
3637
3645
|
"not_publishable",
|
|
3638
3646
|
"invalid_connection",
|
|
3639
3647
|
"invalid_media",
|
|
@@ -4825,6 +4833,8 @@ z__namespace.object({
|
|
|
4825
4833
|
"ONE_PER_CLICK",
|
|
4826
4834
|
"MANY_PER_CLICK"
|
|
4827
4835
|
]),
|
|
4836
|
+
click_through_lookback_window_days: z__namespace.number().nullable(),
|
|
4837
|
+
view_through_lookback_window_days: z__namespace.number().nullable(),
|
|
4828
4838
|
value_settings: z__namespace.object({
|
|
4829
4839
|
default_value: z__namespace.number().nullable(),
|
|
4830
4840
|
default_currency_code: z__namespace.string().nullable(),
|
|
@@ -5004,6 +5014,8 @@ z__namespace.object({
|
|
|
5004
5014
|
"ONE_PER_CLICK",
|
|
5005
5015
|
"MANY_PER_CLICK"
|
|
5006
5016
|
]),
|
|
5017
|
+
click_through_lookback_window_days: z__namespace.number().nullable(),
|
|
5018
|
+
view_through_lookback_window_days: z__namespace.number().nullable(),
|
|
5007
5019
|
value_settings: z__namespace.object({
|
|
5008
5020
|
default_value: z__namespace.number().nullable(),
|
|
5009
5021
|
default_currency_code: z__namespace.string().nullable(),
|
|
@@ -5028,6 +5040,61 @@ z__namespace.object({
|
|
|
5028
5040
|
event_snippet: z__namespace.string().nullable()
|
|
5029
5041
|
}))
|
|
5030
5042
|
});
|
|
5043
|
+
z__namespace.object({
|
|
5044
|
+
name: z__namespace.string().min(1).max(255).optional(),
|
|
5045
|
+
category: z__namespace.enum([
|
|
5046
|
+
"DEFAULT",
|
|
5047
|
+
"PAGE_VIEW",
|
|
5048
|
+
"PURCHASE",
|
|
5049
|
+
"SIGNUP",
|
|
5050
|
+
"DOWNLOAD",
|
|
5051
|
+
"ADD_TO_CART",
|
|
5052
|
+
"BEGIN_CHECKOUT",
|
|
5053
|
+
"SUBSCRIBE_PAID",
|
|
5054
|
+
"PHONE_CALL_LEAD",
|
|
5055
|
+
"IMPORTED_LEAD",
|
|
5056
|
+
"SUBMIT_LEAD_FORM",
|
|
5057
|
+
"BOOK_APPOINTMENT",
|
|
5058
|
+
"REQUEST_QUOTE",
|
|
5059
|
+
"GET_DIRECTIONS",
|
|
5060
|
+
"OUTBOUND_CLICK",
|
|
5061
|
+
"CONTACT",
|
|
5062
|
+
"ENGAGEMENT",
|
|
5063
|
+
"STORE_VISIT",
|
|
5064
|
+
"STORE_SALE",
|
|
5065
|
+
"QUALIFIED_LEAD",
|
|
5066
|
+
"CONVERTED_LEAD",
|
|
5067
|
+
"YOUTUBE_FOLLOW_ON_VIEWS"
|
|
5068
|
+
]).optional(),
|
|
5069
|
+
status: z__namespace.enum(["ENABLED"]).optional(),
|
|
5070
|
+
value_settings: z__namespace.object({
|
|
5071
|
+
default_value: z__namespace.number().gte(0).optional(),
|
|
5072
|
+
default_currency_code: z__namespace.string().length(3).optional(),
|
|
5073
|
+
always_use_default_value: z__namespace.boolean().optional()
|
|
5074
|
+
}).optional(),
|
|
5075
|
+
counting_type: z__namespace.enum(["ONE_PER_CLICK", "MANY_PER_CLICK"]).optional(),
|
|
5076
|
+
click_through_lookback_window_days: z__namespace.int().gt(0).lte(9007199254740991).optional(),
|
|
5077
|
+
view_through_lookback_window_days: z__namespace.int().gt(0).lte(9007199254740991).optional(),
|
|
5078
|
+
primary_for_goal: z__namespace.boolean().optional(),
|
|
5079
|
+
dry_run: z__namespace.boolean().optional().default(false)
|
|
5080
|
+
});
|
|
5081
|
+
z__namespace.object({
|
|
5082
|
+
"Idempotency-Key": z__namespace.string().min(1).max(255).optional()
|
|
5083
|
+
});
|
|
5084
|
+
z__namespace.object({
|
|
5085
|
+
connection_id: z__namespace.string(),
|
|
5086
|
+
id: z__namespace.string().regex(/^\d+$/)
|
|
5087
|
+
});
|
|
5088
|
+
z__namespace.object({
|
|
5089
|
+
dry_run: z__namespace.boolean().optional().default(false)
|
|
5090
|
+
});
|
|
5091
|
+
z__namespace.object({
|
|
5092
|
+
"Idempotency-Key": z__namespace.string().min(1).max(255).optional()
|
|
5093
|
+
});
|
|
5094
|
+
z__namespace.object({
|
|
5095
|
+
connection_id: z__namespace.string(),
|
|
5096
|
+
id: z__namespace.string().regex(/^\d+$/)
|
|
5097
|
+
});
|
|
5031
5098
|
z__namespace.object({
|
|
5032
5099
|
conversion_action_id: z__namespace.string().regex(/^\d+$/),
|
|
5033
5100
|
conversions: z__namespace.array(zGoogleAdsConversionEvent).min(1).max(2e3),
|
|
@@ -5285,6 +5352,7 @@ z__namespace.object({
|
|
|
5285
5352
|
"media_processing",
|
|
5286
5353
|
"media_upload_init_failed",
|
|
5287
5354
|
"media_upload_incomplete",
|
|
5355
|
+
"media_upload_invalid_parts",
|
|
5288
5356
|
"not_publishable",
|
|
5289
5357
|
"invalid_connection",
|
|
5290
5358
|
"invalid_media",
|
|
@@ -5444,6 +5512,7 @@ z__namespace.object({
|
|
|
5444
5512
|
"media_processing",
|
|
5445
5513
|
"media_upload_init_failed",
|
|
5446
5514
|
"media_upload_incomplete",
|
|
5515
|
+
"media_upload_invalid_parts",
|
|
5447
5516
|
"not_publishable",
|
|
5448
5517
|
"invalid_connection",
|
|
5449
5518
|
"invalid_media",
|
|
@@ -5624,6 +5693,7 @@ z__namespace.object({
|
|
|
5624
5693
|
"media_processing",
|
|
5625
5694
|
"media_upload_init_failed",
|
|
5626
5695
|
"media_upload_incomplete",
|
|
5696
|
+
"media_upload_invalid_parts",
|
|
5627
5697
|
"not_publishable",
|
|
5628
5698
|
"invalid_connection",
|
|
5629
5699
|
"invalid_media",
|
|
@@ -5783,6 +5853,7 @@ z__namespace.object({
|
|
|
5783
5853
|
"media_processing",
|
|
5784
5854
|
"media_upload_init_failed",
|
|
5785
5855
|
"media_upload_incomplete",
|
|
5856
|
+
"media_upload_invalid_parts",
|
|
5786
5857
|
"not_publishable",
|
|
5787
5858
|
"invalid_connection",
|
|
5788
5859
|
"invalid_media",
|
|
@@ -6070,8 +6141,54 @@ var PostrunError = class extends Error {
|
|
|
6070
6141
|
}
|
|
6071
6142
|
};
|
|
6072
6143
|
|
|
6144
|
+
// src/token-cache.ts
|
|
6145
|
+
function createTokenCache(getToken) {
|
|
6146
|
+
let cached;
|
|
6147
|
+
let inFlight;
|
|
6148
|
+
const mint = () => {
|
|
6149
|
+
if (!inFlight) {
|
|
6150
|
+
inFlight = Promise.resolve().then(getToken).then((token) => {
|
|
6151
|
+
cached = token;
|
|
6152
|
+
return token;
|
|
6153
|
+
}).finally(() => {
|
|
6154
|
+
inFlight = void 0;
|
|
6155
|
+
});
|
|
6156
|
+
}
|
|
6157
|
+
return inFlight;
|
|
6158
|
+
};
|
|
6159
|
+
return {
|
|
6160
|
+
current() {
|
|
6161
|
+
return cached !== void 0 ? Promise.resolve(cached) : mint();
|
|
6162
|
+
},
|
|
6163
|
+
refresh() {
|
|
6164
|
+
cached = void 0;
|
|
6165
|
+
return mint();
|
|
6166
|
+
}
|
|
6167
|
+
};
|
|
6168
|
+
}
|
|
6169
|
+
|
|
6073
6170
|
// src/client.ts
|
|
6074
6171
|
var DEFAULT_BASE_URL = "https://api.postrun.ai/v1";
|
|
6172
|
+
var UNAUTHORIZED = 401;
|
|
6173
|
+
function createRetryingFetch(tokenCache) {
|
|
6174
|
+
const realFetch = (...args) => globalThis.fetch(...args);
|
|
6175
|
+
return async (input, init) => {
|
|
6176
|
+
const request = new Request(input, init);
|
|
6177
|
+
const retryable = request.clone();
|
|
6178
|
+
const response = await realFetch(request);
|
|
6179
|
+
if (response.status !== UNAUTHORIZED) {
|
|
6180
|
+
return response;
|
|
6181
|
+
}
|
|
6182
|
+
try {
|
|
6183
|
+
const token = await tokenCache.refresh();
|
|
6184
|
+
const headers = new Headers(retryable.headers);
|
|
6185
|
+
headers.set("Authorization", `Bearer ${token}`);
|
|
6186
|
+
return await realFetch(new Request(retryable, { headers }));
|
|
6187
|
+
} catch {
|
|
6188
|
+
return response;
|
|
6189
|
+
}
|
|
6190
|
+
};
|
|
6191
|
+
}
|
|
6075
6192
|
function appendScalar(parts, key, value) {
|
|
6076
6193
|
parts.push(
|
|
6077
6194
|
`${encodeURIComponent(key)}=${encodeURIComponent(String(value))}`
|
|
@@ -6098,10 +6215,12 @@ function serializeQuery(query) {
|
|
|
6098
6215
|
return parts.join("&");
|
|
6099
6216
|
}
|
|
6100
6217
|
function createPostrunClient(options) {
|
|
6218
|
+
const tokenCache = createTokenCache(options.getToken);
|
|
6101
6219
|
const client2 = createClient(
|
|
6102
6220
|
createConfig({
|
|
6103
6221
|
baseUrl: options.baseUrl ?? DEFAULT_BASE_URL,
|
|
6104
|
-
auth: () =>
|
|
6222
|
+
auth: () => tokenCache.current(),
|
|
6223
|
+
fetch: createRetryingFetch(tokenCache),
|
|
6105
6224
|
querySerializer: serializeQuery,
|
|
6106
6225
|
throwOnError: true
|
|
6107
6226
|
})
|