@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
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { zErrorCode } from './chunk-
|
|
1
|
+
import { zErrorCode } from './chunk-A6DM6I6G.js';
|
|
2
2
|
import * as z from 'zod';
|
|
3
3
|
|
|
4
4
|
var ProblemSchema = z.object({
|
|
@@ -810,8 +810,54 @@ var createClient = (config = {}) => {
|
|
|
810
810
|
};
|
|
811
811
|
};
|
|
812
812
|
|
|
813
|
+
// src/token-cache.ts
|
|
814
|
+
function createTokenCache(getToken) {
|
|
815
|
+
let cached;
|
|
816
|
+
let inFlight;
|
|
817
|
+
const mint = () => {
|
|
818
|
+
if (!inFlight) {
|
|
819
|
+
inFlight = Promise.resolve().then(getToken).then((token) => {
|
|
820
|
+
cached = token;
|
|
821
|
+
return token;
|
|
822
|
+
}).finally(() => {
|
|
823
|
+
inFlight = void 0;
|
|
824
|
+
});
|
|
825
|
+
}
|
|
826
|
+
return inFlight;
|
|
827
|
+
};
|
|
828
|
+
return {
|
|
829
|
+
current() {
|
|
830
|
+
return cached !== void 0 ? Promise.resolve(cached) : mint();
|
|
831
|
+
},
|
|
832
|
+
refresh() {
|
|
833
|
+
cached = void 0;
|
|
834
|
+
return mint();
|
|
835
|
+
}
|
|
836
|
+
};
|
|
837
|
+
}
|
|
838
|
+
|
|
813
839
|
// src/client.ts
|
|
814
840
|
var DEFAULT_BASE_URL = "https://api.postrun.ai/v1";
|
|
841
|
+
var UNAUTHORIZED = 401;
|
|
842
|
+
function createRetryingFetch(tokenCache) {
|
|
843
|
+
const realFetch = (...args) => globalThis.fetch(...args);
|
|
844
|
+
return async (input, init) => {
|
|
845
|
+
const request = new Request(input, init);
|
|
846
|
+
const retryable = request.clone();
|
|
847
|
+
const response = await realFetch(request);
|
|
848
|
+
if (response.status !== UNAUTHORIZED) {
|
|
849
|
+
return response;
|
|
850
|
+
}
|
|
851
|
+
try {
|
|
852
|
+
const token = await tokenCache.refresh();
|
|
853
|
+
const headers = new Headers(retryable.headers);
|
|
854
|
+
headers.set("Authorization", `Bearer ${token}`);
|
|
855
|
+
return await realFetch(new Request(retryable, { headers }));
|
|
856
|
+
} catch {
|
|
857
|
+
return response;
|
|
858
|
+
}
|
|
859
|
+
};
|
|
860
|
+
}
|
|
815
861
|
function appendScalar(parts, key, value) {
|
|
816
862
|
parts.push(
|
|
817
863
|
`${encodeURIComponent(key)}=${encodeURIComponent(String(value))}`
|
|
@@ -838,10 +884,12 @@ function serializeQuery(query) {
|
|
|
838
884
|
return parts.join("&");
|
|
839
885
|
}
|
|
840
886
|
function createPostrunClient(options) {
|
|
887
|
+
const tokenCache = createTokenCache(options.getToken);
|
|
841
888
|
const client2 = createClient(
|
|
842
889
|
createConfig({
|
|
843
890
|
baseUrl: options.baseUrl ?? DEFAULT_BASE_URL,
|
|
844
|
-
auth: () =>
|
|
891
|
+
auth: () => tokenCache.current(),
|
|
892
|
+
fetch: createRetryingFetch(tokenCache),
|
|
845
893
|
querySerializer: serializeQuery,
|
|
846
894
|
throwOnError: true
|
|
847
895
|
})
|
|
@@ -2112,6 +2160,40 @@ var googleGetConversionAction = (options) => (options.client ?? client).get({
|
|
|
2112
2160
|
url: "/google/{connection_id}/conversion-actions/{id}",
|
|
2113
2161
|
...options
|
|
2114
2162
|
});
|
|
2163
|
+
var googleUpdateConversionAction = (options) => (options.client ?? client).patch({
|
|
2164
|
+
security: [{
|
|
2165
|
+
key: "secretKey",
|
|
2166
|
+
scheme: "bearer",
|
|
2167
|
+
type: "http"
|
|
2168
|
+
}, {
|
|
2169
|
+
key: "frontendToken",
|
|
2170
|
+
scheme: "bearer",
|
|
2171
|
+
type: "http"
|
|
2172
|
+
}],
|
|
2173
|
+
url: "/google/{connection_id}/conversion-actions/{id}",
|
|
2174
|
+
...options,
|
|
2175
|
+
headers: {
|
|
2176
|
+
"Content-Type": "application/json",
|
|
2177
|
+
...options.headers
|
|
2178
|
+
}
|
|
2179
|
+
});
|
|
2180
|
+
var googleRemoveConversionAction = (options) => (options.client ?? client).post({
|
|
2181
|
+
security: [{
|
|
2182
|
+
key: "secretKey",
|
|
2183
|
+
scheme: "bearer",
|
|
2184
|
+
type: "http"
|
|
2185
|
+
}, {
|
|
2186
|
+
key: "frontendToken",
|
|
2187
|
+
scheme: "bearer",
|
|
2188
|
+
type: "http"
|
|
2189
|
+
}],
|
|
2190
|
+
url: "/google/{connection_id}/conversion-actions/{id}/remove",
|
|
2191
|
+
...options,
|
|
2192
|
+
headers: {
|
|
2193
|
+
"Content-Type": "application/json",
|
|
2194
|
+
...options.headers
|
|
2195
|
+
}
|
|
2196
|
+
});
|
|
2115
2197
|
var googleSendConversions = (options) => (options.client ?? client).post({
|
|
2116
2198
|
security: [{
|
|
2117
2199
|
key: "secretKey",
|
|
@@ -2331,6 +2413,6 @@ var tokensMint = (options) => (options.client ?? client).post({
|
|
|
2331
2413
|
}
|
|
2332
2414
|
});
|
|
2333
2415
|
|
|
2334
|
-
export { PostrunError, connectionsConnect, connectionsDelete, connectionsGet, connectionsListAccounts, connectionsListByProfile, connectionsSelect, createPostrunClient, googleCreateAd, googleCreateAdGroup, googleCreateAdGroupCriterion, googleCreateBudget, googleCreateCampaign, googleCreateCampaignCriterion, googleCreateConversionAction, googleCreateDisplayAd, googleCreateKeyword, googleEditAccount, googleEditAdGroup, googleEditBudget, googleEditCampaign, googleEnableAd, googleEnableAdGroup, googleEnableCampaign, googleEnableKeyword, googleGetAccount, googleGetAd, googleGetAdGroup, googleGetAdTree, googleGetCampaign, googleGetConversionAction, googleGetConversionStatus, googleGetInsights, googleGetKeyword, googleListAdGroupCriteria, googleListAdGroups, googleListAds, googleListAudiences, googleListCampaignCriteria, googleListCampaigns, googleListConversionActions, googleListConversionGoals, googleListConversionRequests, googleListKeywords, googlePauseAd, googlePauseAdGroup, googlePauseCampaign, googlePauseKeyword, googleRemoveAd, googleRemoveAdGroup, googleRemoveAdGroupCriterion, googleRemoveBudget, googleRemoveCampaign, googleRemoveCampaignCriterion, googleRemoveKeyword, googleRunGaql, googleSearchGeoTargets, googleSendConversions, googleSetAdGroupBids, googleSetCampaignGeoSettings, googleSetCampaignTargetingSetting, googleSetConversionGoal, googleSetKeywordBid, googleUploadImageAsset, logsGet, logsList, mediaAbort, mediaComplete, mediaCreate, mediaDelete, mediaGet, mediaList, mediaListParts, mediaSignPart, mediaUpdate, metaAccount, metaAd, metaAds, metaAdset, metaAdsets, metaCampaign, metaCampaigns, metaInsights, postsCreate, postsDelete, postsGet, postsList, postsUpdate, postsValidate, profilesCreate, profilesDelete, profilesGet, profilesList, profilesUpdate, tiktokCreatorInfo, tokensMint, webhooksCreateEndpoint, webhooksCreatePortal, webhooksDeleteEndpoint, webhooksGetEndpoint, webhooksListEndpoints, webhooksListEventTypes, webhooksPing, webhooksUpdateEndpoint };
|
|
2335
|
-
//# sourceMappingURL=chunk-
|
|
2336
|
-
//# sourceMappingURL=chunk-
|
|
2416
|
+
export { PostrunError, connectionsConnect, connectionsDelete, connectionsGet, connectionsListAccounts, connectionsListByProfile, connectionsSelect, createPostrunClient, googleCreateAd, googleCreateAdGroup, googleCreateAdGroupCriterion, googleCreateBudget, googleCreateCampaign, googleCreateCampaignCriterion, googleCreateConversionAction, googleCreateDisplayAd, googleCreateKeyword, googleEditAccount, googleEditAdGroup, googleEditBudget, googleEditCampaign, googleEnableAd, googleEnableAdGroup, googleEnableCampaign, googleEnableKeyword, googleGetAccount, googleGetAd, googleGetAdGroup, googleGetAdTree, googleGetCampaign, googleGetConversionAction, googleGetConversionStatus, googleGetInsights, googleGetKeyword, googleListAdGroupCriteria, googleListAdGroups, googleListAds, googleListAudiences, googleListCampaignCriteria, googleListCampaigns, googleListConversionActions, googleListConversionGoals, googleListConversionRequests, googleListKeywords, googlePauseAd, googlePauseAdGroup, googlePauseCampaign, googlePauseKeyword, googleRemoveAd, googleRemoveAdGroup, googleRemoveAdGroupCriterion, googleRemoveBudget, googleRemoveCampaign, googleRemoveCampaignCriterion, googleRemoveConversionAction, googleRemoveKeyword, googleRunGaql, googleSearchGeoTargets, googleSendConversions, googleSetAdGroupBids, googleSetCampaignGeoSettings, googleSetCampaignTargetingSetting, googleSetConversionGoal, googleSetKeywordBid, googleUpdateConversionAction, googleUploadImageAsset, logsGet, logsList, mediaAbort, mediaComplete, mediaCreate, mediaDelete, mediaGet, mediaList, mediaListParts, mediaSignPart, mediaUpdate, metaAccount, metaAd, metaAds, metaAdset, metaAdsets, metaCampaign, metaCampaigns, metaInsights, postsCreate, postsDelete, postsGet, postsList, postsUpdate, postsValidate, profilesCreate, profilesDelete, profilesGet, profilesList, profilesUpdate, tiktokCreatorInfo, tokensMint, webhooksCreateEndpoint, webhooksCreatePortal, webhooksDeleteEndpoint, webhooksGetEndpoint, webhooksListEndpoints, webhooksListEventTypes, webhooksPing, webhooksUpdateEndpoint };
|
|
2417
|
+
//# sourceMappingURL=chunk-PE3ULG66.js.map
|
|
2418
|
+
//# sourceMappingURL=chunk-PE3ULG66.js.map
|