soundlink 2.8.0 → 2.10.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 +16 -0
- package/README.md +38 -0
- package/dist/cjs/api-emulator.cjs +934 -0
- package/dist/cjs/api-emulator.cjs.map +1 -0
- package/dist/cjs/index.cjs +22 -1
- package/dist/cjs/index.cjs.map +1 -1
- package/dist/esm/api-BCcqXQoy.d.ts +864 -0
- package/dist/esm/api-emulator.d.ts +127 -0
- package/dist/esm/api-emulator.js +930 -0
- package/dist/esm/api-emulator.js.map +1 -0
- package/dist/esm/index.d.ts +18 -851
- package/dist/esm/index.js +22 -1
- package/dist/esm/index.js.map +1 -1
- package/docs/api-emulator.md +216 -0
- package/openapi/soundlink-public-api-v1.yaml +126 -25
- package/package.json +12 -1
|
@@ -0,0 +1,934 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
var crypto = require('crypto');
|
|
4
|
+
var http = require('http');
|
|
5
|
+
|
|
6
|
+
// src/emulator/dispatch.ts
|
|
7
|
+
|
|
8
|
+
// src/emulator/money.ts
|
|
9
|
+
function computeCommittedUsd(dailyBudget, durationDays) {
|
|
10
|
+
return Math.round(dailyBudget * durationDays * 100) / 100;
|
|
11
|
+
}
|
|
12
|
+
function computeRefundGrossFromRawSpend(mediaSpendUsd, committedUsd, feeRate) {
|
|
13
|
+
const rate = Math.max(0, Math.min(feeRate, 0.9999));
|
|
14
|
+
const grossEquivSpend = rate > 0 ? mediaSpendUsd / (1 - rate) : mediaSpendUsd;
|
|
15
|
+
return Math.max(0, Number((committedUsd - grossEquivSpend).toFixed(2)));
|
|
16
|
+
}
|
|
17
|
+
var ORG_EMULATOR_ID = "org_emulator";
|
|
18
|
+
function nowIso() {
|
|
19
|
+
return (/* @__PURE__ */ new Date()).toISOString();
|
|
20
|
+
}
|
|
21
|
+
function emptyOverview() {
|
|
22
|
+
return {
|
|
23
|
+
listeners: 0,
|
|
24
|
+
total_listeners: 0,
|
|
25
|
+
streams: 0,
|
|
26
|
+
followers: 0,
|
|
27
|
+
impressions: null,
|
|
28
|
+
ad_clicks: null,
|
|
29
|
+
link_clicks: null,
|
|
30
|
+
spend_media: 0,
|
|
31
|
+
spend_total: 0,
|
|
32
|
+
fees: 0,
|
|
33
|
+
currency: "USD",
|
|
34
|
+
cpl: 0,
|
|
35
|
+
cpf: 0,
|
|
36
|
+
streams_per_listener: 0
|
|
37
|
+
};
|
|
38
|
+
}
|
|
39
|
+
var DEFAULT_ACTIVATE_LISTENERS = 120;
|
|
40
|
+
var DEFAULT_ACTIVATE_TOTAL_LISTENERS = 150;
|
|
41
|
+
var DEFAULT_ACTIVATE_STREAMS = 450;
|
|
42
|
+
var DEFAULT_ACTIVATE_FOLLOWERS = 18;
|
|
43
|
+
function seedOverviewAfterActivate(listenersGranted) {
|
|
44
|
+
const scale = listenersGranted / DEFAULT_ACTIVATE_LISTENERS;
|
|
45
|
+
const listeners = listenersGranted;
|
|
46
|
+
const totalListeners = Math.round(DEFAULT_ACTIVATE_TOTAL_LISTENERS * scale);
|
|
47
|
+
const streams = Math.round(DEFAULT_ACTIVATE_STREAMS * scale);
|
|
48
|
+
const followers = Math.round(DEFAULT_ACTIVATE_FOLLOWERS * scale);
|
|
49
|
+
return {
|
|
50
|
+
listeners,
|
|
51
|
+
total_listeners: totalListeners,
|
|
52
|
+
streams,
|
|
53
|
+
followers,
|
|
54
|
+
impressions: listeners > 0 ? 8e3 : 0,
|
|
55
|
+
ad_clicks: listeners > 0 ? 400 : 0,
|
|
56
|
+
link_clicks: listeners > 0 ? 220 : 0,
|
|
57
|
+
spend_media: 0,
|
|
58
|
+
spend_total: 0,
|
|
59
|
+
fees: 0,
|
|
60
|
+
currency: "USD",
|
|
61
|
+
cpl: 0,
|
|
62
|
+
cpf: 0,
|
|
63
|
+
streams_per_listener: totalListeners > 0 ? Number((streams / totalListeners).toFixed(4)) : 0
|
|
64
|
+
};
|
|
65
|
+
}
|
|
66
|
+
function parseSpotifyIds(spotifyUrl) {
|
|
67
|
+
const trackMatch = /track\/([a-zA-Z0-9]+)/.exec(spotifyUrl);
|
|
68
|
+
const trackId = trackMatch?.[1];
|
|
69
|
+
if (typeof trackId === "string") {
|
|
70
|
+
return { trackId, playlistId: null };
|
|
71
|
+
}
|
|
72
|
+
const playlistMatch = /playlist\/([a-zA-Z0-9]+)/.exec(spotifyUrl);
|
|
73
|
+
const playlistId = playlistMatch?.[1];
|
|
74
|
+
if (typeof playlistId === "string") {
|
|
75
|
+
return { trackId: null, playlistId };
|
|
76
|
+
}
|
|
77
|
+
return { trackId: null, playlistId: null };
|
|
78
|
+
}
|
|
79
|
+
function roundMoney(value) {
|
|
80
|
+
return Number(value.toFixed(2));
|
|
81
|
+
}
|
|
82
|
+
function createEmulatorStore(options) {
|
|
83
|
+
const organizationId = options.organizationId ?? ORG_EMULATOR_ID;
|
|
84
|
+
let balance = roundMoney(options.initialWalletBalance);
|
|
85
|
+
let updatedAt = nowIso();
|
|
86
|
+
const campaigns = /* @__PURE__ */ new Map();
|
|
87
|
+
const idempotency = /* @__PURE__ */ new Map();
|
|
88
|
+
const store = {
|
|
89
|
+
apiKey: options.apiKey,
|
|
90
|
+
feeRate: options.feeRate,
|
|
91
|
+
organizationId,
|
|
92
|
+
initialWalletBalance: options.initialWalletBalance,
|
|
93
|
+
reset() {
|
|
94
|
+
balance = roundMoney(options.initialWalletBalance);
|
|
95
|
+
updatedAt = nowIso();
|
|
96
|
+
campaigns.clear();
|
|
97
|
+
idempotency.clear();
|
|
98
|
+
},
|
|
99
|
+
getWallet() {
|
|
100
|
+
return {
|
|
101
|
+
balance,
|
|
102
|
+
available: balance,
|
|
103
|
+
reserved: 0,
|
|
104
|
+
currency: "USD",
|
|
105
|
+
updatedAt
|
|
106
|
+
};
|
|
107
|
+
},
|
|
108
|
+
setWalletBalance(nextBalance) {
|
|
109
|
+
balance = roundMoney(nextBalance);
|
|
110
|
+
updatedAt = nowIso();
|
|
111
|
+
return store.getWallet();
|
|
112
|
+
},
|
|
113
|
+
listCampaigns() {
|
|
114
|
+
return [...campaigns.values()].sort(
|
|
115
|
+
(a, b) => a.createdAt < b.createdAt ? 1 : -1
|
|
116
|
+
);
|
|
117
|
+
},
|
|
118
|
+
getCampaign(campaignId) {
|
|
119
|
+
return campaigns.get(campaignId);
|
|
120
|
+
},
|
|
121
|
+
createCampaign(input) {
|
|
122
|
+
const committedUsd = computeCommittedUsd(input.dailyBudget, input.durationDays);
|
|
123
|
+
const ids = parseSpotifyIds(input.spotifyUrl);
|
|
124
|
+
const timestamp = nowIso();
|
|
125
|
+
const campaignId = `cmp_${crypto.randomUUID().replace(/-/g, "").slice(0, 16)}`;
|
|
126
|
+
const record = {
|
|
127
|
+
campaignId,
|
|
128
|
+
status: "creating",
|
|
129
|
+
dailyBudget: input.dailyBudget,
|
|
130
|
+
durationDays: input.durationDays,
|
|
131
|
+
committedUsd,
|
|
132
|
+
mediaSpendUsd: 0,
|
|
133
|
+
refundedAt: null,
|
|
134
|
+
autoRenew: input.autoRenew,
|
|
135
|
+
strategyType: input.strategyType,
|
|
136
|
+
spotifyUrl: input.spotifyUrl,
|
|
137
|
+
genre: input.genre,
|
|
138
|
+
campaignName: input.campaignName ?? `Emulator campaign ${campaignId}`,
|
|
139
|
+
trackId: ids.trackId,
|
|
140
|
+
playlistId: ids.playlistId,
|
|
141
|
+
artistId: null,
|
|
142
|
+
artistName: null,
|
|
143
|
+
trackName: ids.trackId ? "Emulator Track" : null,
|
|
144
|
+
createdAt: timestamp,
|
|
145
|
+
updatedAt: timestamp,
|
|
146
|
+
overview: null
|
|
147
|
+
};
|
|
148
|
+
campaigns.set(campaignId, record);
|
|
149
|
+
return record;
|
|
150
|
+
},
|
|
151
|
+
updateCampaign(campaign) {
|
|
152
|
+
campaign.updatedAt = nowIso();
|
|
153
|
+
campaigns.set(campaign.campaignId, campaign);
|
|
154
|
+
},
|
|
155
|
+
creditWallet(amount) {
|
|
156
|
+
if (!Number.isFinite(amount) || amount <= 0) return;
|
|
157
|
+
balance = roundMoney(balance + amount);
|
|
158
|
+
updatedAt = nowIso();
|
|
159
|
+
},
|
|
160
|
+
debitWallet(amount) {
|
|
161
|
+
if (!Number.isFinite(amount) || amount <= 0) {
|
|
162
|
+
throw new Error("debitWallet requires a finite positive amount.");
|
|
163
|
+
}
|
|
164
|
+
if (amount > balance) {
|
|
165
|
+
throw new Error("debitWallet would make wallet balance negative.");
|
|
166
|
+
}
|
|
167
|
+
balance = roundMoney(balance - amount);
|
|
168
|
+
updatedAt = nowIso();
|
|
169
|
+
},
|
|
170
|
+
getIdempotency(key) {
|
|
171
|
+
return idempotency.get(key);
|
|
172
|
+
},
|
|
173
|
+
setIdempotency(key, record) {
|
|
174
|
+
idempotency.set(key, record);
|
|
175
|
+
},
|
|
176
|
+
deleteIdempotency(key) {
|
|
177
|
+
idempotency.delete(key);
|
|
178
|
+
},
|
|
179
|
+
toCampaignDetail(campaign) {
|
|
180
|
+
return {
|
|
181
|
+
campaignId: campaign.campaignId,
|
|
182
|
+
organizationId,
|
|
183
|
+
status: campaign.status,
|
|
184
|
+
socialPlatform: "meta",
|
|
185
|
+
dailyBudget: campaign.dailyBudget,
|
|
186
|
+
totalBudget: campaign.committedUsd,
|
|
187
|
+
campaignDuration: campaign.durationDays,
|
|
188
|
+
generation: 3,
|
|
189
|
+
artistId: campaign.artistId,
|
|
190
|
+
artistName: campaign.artistName,
|
|
191
|
+
trackId: campaign.trackId,
|
|
192
|
+
playlistId: campaign.playlistId,
|
|
193
|
+
trackName: campaign.trackName,
|
|
194
|
+
campaignUrl: `https://app.getsoundlink.com/campaigns/${campaign.campaignId}`,
|
|
195
|
+
createdAt: campaign.createdAt,
|
|
196
|
+
updatedAt: campaign.updatedAt,
|
|
197
|
+
strategyType: campaign.strategyType,
|
|
198
|
+
autoRenew: campaign.autoRenew,
|
|
199
|
+
nextRenewalAt: null
|
|
200
|
+
};
|
|
201
|
+
},
|
|
202
|
+
buildOverview(campaign) {
|
|
203
|
+
const base = campaign.overview ?? emptyOverview();
|
|
204
|
+
const spendMedia = campaign.mediaSpendUsd;
|
|
205
|
+
const rate = store.feeRate;
|
|
206
|
+
const fees = rate > 0 && spendMedia > 0 ? Number((spendMedia / (1 - rate) - spendMedia).toFixed(2)) : 0;
|
|
207
|
+
const listeners = base.listeners;
|
|
208
|
+
const followers = base.followers;
|
|
209
|
+
return {
|
|
210
|
+
...base,
|
|
211
|
+
spend_media: spendMedia,
|
|
212
|
+
spend_total: Number((spendMedia + fees).toFixed(2)),
|
|
213
|
+
fees,
|
|
214
|
+
cpl: listeners > 0 ? Number((spendMedia / listeners).toFixed(4)) : 0,
|
|
215
|
+
cpf: followers > 0 ? Number((spendMedia / followers).toFixed(4)) : 0
|
|
216
|
+
};
|
|
217
|
+
}
|
|
218
|
+
};
|
|
219
|
+
return store;
|
|
220
|
+
}
|
|
221
|
+
function seedOverview(campaign) {
|
|
222
|
+
campaign.overview = seedOverviewAfterActivate(DEFAULT_ACTIVATE_LISTENERS);
|
|
223
|
+
}
|
|
224
|
+
function hashPayload(value) {
|
|
225
|
+
return crypto.createHash("sha256").update(stableStringify(value)).digest("hex");
|
|
226
|
+
}
|
|
227
|
+
function stableStringify(value) {
|
|
228
|
+
if (value === null || typeof value !== "object") {
|
|
229
|
+
return JSON.stringify(value);
|
|
230
|
+
}
|
|
231
|
+
if (Array.isArray(value)) {
|
|
232
|
+
return `[${value.map((item) => stableStringify(item)).join(",")}]`;
|
|
233
|
+
}
|
|
234
|
+
const entries = Object.entries(value).sort(
|
|
235
|
+
([a], [b]) => a.localeCompare(b)
|
|
236
|
+
);
|
|
237
|
+
return `{${entries.map(([key, entryValue]) => `${JSON.stringify(key)}:${stableStringify(entryValue)}`).join(",")}}`;
|
|
238
|
+
}
|
|
239
|
+
|
|
240
|
+
// src/emulator/transitions.ts
|
|
241
|
+
var TransitionError = class extends Error {
|
|
242
|
+
status;
|
|
243
|
+
code;
|
|
244
|
+
constructor(status, code, message) {
|
|
245
|
+
super(message);
|
|
246
|
+
this.name = "TransitionError";
|
|
247
|
+
this.status = status;
|
|
248
|
+
this.code = code;
|
|
249
|
+
}
|
|
250
|
+
};
|
|
251
|
+
function applyRefundIfNeeded(store, campaign) {
|
|
252
|
+
if (campaign.refundedAt) {
|
|
253
|
+
return;
|
|
254
|
+
}
|
|
255
|
+
const refund = computeRefundGrossFromRawSpend(
|
|
256
|
+
campaign.mediaSpendUsd,
|
|
257
|
+
campaign.committedUsd,
|
|
258
|
+
store.feeRate
|
|
259
|
+
);
|
|
260
|
+
store.creditWallet(refund);
|
|
261
|
+
campaign.refundedAt = (/* @__PURE__ */ new Date()).toISOString();
|
|
262
|
+
}
|
|
263
|
+
function applyTransition(store, campaignId, action, mediaSpendUsd) {
|
|
264
|
+
const campaign = store.getCampaign(campaignId);
|
|
265
|
+
if (!campaign) {
|
|
266
|
+
throw new TransitionError(404, "campaign_not_found", "Campaign not found.");
|
|
267
|
+
}
|
|
268
|
+
switch (action) {
|
|
269
|
+
case "activate": {
|
|
270
|
+
if (campaign.status !== "creating") {
|
|
271
|
+
throw new TransitionError(
|
|
272
|
+
400,
|
|
273
|
+
"invalid_request",
|
|
274
|
+
`Cannot activate campaign in status "${campaign.status}".`
|
|
275
|
+
);
|
|
276
|
+
}
|
|
277
|
+
campaign.status = "active";
|
|
278
|
+
seedOverview(campaign);
|
|
279
|
+
store.updateCampaign(campaign);
|
|
280
|
+
break;
|
|
281
|
+
}
|
|
282
|
+
case "reject_meta": {
|
|
283
|
+
if (campaign.status !== "creating" && campaign.status !== "active") {
|
|
284
|
+
throw new TransitionError(
|
|
285
|
+
400,
|
|
286
|
+
"invalid_request",
|
|
287
|
+
`Cannot reject_meta campaign in status "${campaign.status}".`
|
|
288
|
+
);
|
|
289
|
+
}
|
|
290
|
+
campaign.status = "inactive";
|
|
291
|
+
store.updateCampaign(campaign);
|
|
292
|
+
break;
|
|
293
|
+
}
|
|
294
|
+
case "set_spend": {
|
|
295
|
+
if (campaign.status !== "creating" && campaign.status !== "active" && campaign.status !== "inactive") {
|
|
296
|
+
throw new TransitionError(
|
|
297
|
+
400,
|
|
298
|
+
"invalid_request",
|
|
299
|
+
`Cannot set_spend campaign in status "${campaign.status}".`
|
|
300
|
+
);
|
|
301
|
+
}
|
|
302
|
+
if (campaign.refundedAt) {
|
|
303
|
+
throw new TransitionError(
|
|
304
|
+
400,
|
|
305
|
+
"invalid_request",
|
|
306
|
+
"Cannot set_spend after refund."
|
|
307
|
+
);
|
|
308
|
+
}
|
|
309
|
+
if (typeof mediaSpendUsd !== "number" || !Number.isFinite(mediaSpendUsd) || mediaSpendUsd < 0 || mediaSpendUsd > campaign.committedUsd) {
|
|
310
|
+
throw new TransitionError(
|
|
311
|
+
400,
|
|
312
|
+
"invalid_request",
|
|
313
|
+
`mediaSpendUsd must be between 0 and ${String(campaign.committedUsd)}.`
|
|
314
|
+
);
|
|
315
|
+
}
|
|
316
|
+
campaign.mediaSpendUsd = Number(mediaSpendUsd.toFixed(2));
|
|
317
|
+
store.updateCampaign(campaign);
|
|
318
|
+
break;
|
|
319
|
+
}
|
|
320
|
+
case "end": {
|
|
321
|
+
if (campaign.status !== "active" && campaign.status !== "inactive") {
|
|
322
|
+
throw new TransitionError(
|
|
323
|
+
400,
|
|
324
|
+
"invalid_request",
|
|
325
|
+
`Cannot end campaign in status "${campaign.status}".`
|
|
326
|
+
);
|
|
327
|
+
}
|
|
328
|
+
campaign.status = "ended";
|
|
329
|
+
applyRefundIfNeeded(store, campaign);
|
|
330
|
+
store.updateCampaign(campaign);
|
|
331
|
+
break;
|
|
332
|
+
}
|
|
333
|
+
default: {
|
|
334
|
+
const _exhaustive = action;
|
|
335
|
+
throw new TransitionError(
|
|
336
|
+
400,
|
|
337
|
+
"invalid_request",
|
|
338
|
+
`Unknown action "${String(_exhaustive)}".`
|
|
339
|
+
);
|
|
340
|
+
}
|
|
341
|
+
}
|
|
342
|
+
return {
|
|
343
|
+
campaignId: campaign.campaignId,
|
|
344
|
+
status: campaign.status,
|
|
345
|
+
mediaSpendUsd: campaign.mediaSpendUsd,
|
|
346
|
+
refundedAt: campaign.refundedAt
|
|
347
|
+
};
|
|
348
|
+
}
|
|
349
|
+
function applyPublicStop(store, campaign) {
|
|
350
|
+
if (campaign.status === "creating" || campaign.status === "renewing") {
|
|
351
|
+
return { status: campaign.status, releasedKey: true };
|
|
352
|
+
}
|
|
353
|
+
if (campaign.status === "stopped" || campaign.status === "ended") {
|
|
354
|
+
return { status: campaign.status, releasedKey: false };
|
|
355
|
+
}
|
|
356
|
+
if (campaign.status !== "active" && campaign.status !== "inactive") {
|
|
357
|
+
return { status: campaign.status, releasedKey: true };
|
|
358
|
+
}
|
|
359
|
+
campaign.status = "stopped";
|
|
360
|
+
applyRefundIfNeeded(store, campaign);
|
|
361
|
+
store.updateCampaign(campaign);
|
|
362
|
+
return { status: "stopped", releasedKey: false };
|
|
363
|
+
}
|
|
364
|
+
|
|
365
|
+
// src/emulator/dispatch.ts
|
|
366
|
+
function parsePathname(path) {
|
|
367
|
+
return new URL(path, "http://emulator.local").pathname;
|
|
368
|
+
}
|
|
369
|
+
function matchPathGroup(pathname, pattern) {
|
|
370
|
+
const match = pattern.exec(pathname);
|
|
371
|
+
const group = match?.[1];
|
|
372
|
+
return typeof group === "string" ? group : void 0;
|
|
373
|
+
}
|
|
374
|
+
function headerValue(headers, name) {
|
|
375
|
+
if (!headers) return void 0;
|
|
376
|
+
const target = name.toLowerCase();
|
|
377
|
+
for (const [key, value] of Object.entries(headers)) {
|
|
378
|
+
if (key.toLowerCase() === target) {
|
|
379
|
+
return value;
|
|
380
|
+
}
|
|
381
|
+
}
|
|
382
|
+
return void 0;
|
|
383
|
+
}
|
|
384
|
+
function success(status, data, requestId = crypto.randomUUID()) {
|
|
385
|
+
return {
|
|
386
|
+
status,
|
|
387
|
+
json: {
|
|
388
|
+
data,
|
|
389
|
+
meta: { requestId }
|
|
390
|
+
}
|
|
391
|
+
};
|
|
392
|
+
}
|
|
393
|
+
function failure(status, code, message, details) {
|
|
394
|
+
return {
|
|
395
|
+
status,
|
|
396
|
+
json: {
|
|
397
|
+
error: {
|
|
398
|
+
code,
|
|
399
|
+
message,
|
|
400
|
+
...details !== void 0 ? { details } : {}
|
|
401
|
+
},
|
|
402
|
+
meta: { requestId: crypto.randomUUID() }
|
|
403
|
+
}
|
|
404
|
+
};
|
|
405
|
+
}
|
|
406
|
+
function requireApiKey(store, headers) {
|
|
407
|
+
const authorization = headerValue(headers, "authorization");
|
|
408
|
+
if (!authorization?.startsWith("Bearer ")) {
|
|
409
|
+
return failure(
|
|
410
|
+
401,
|
|
411
|
+
"invalid_api_key",
|
|
412
|
+
"Missing credentials. Send Authorization: Bearer."
|
|
413
|
+
);
|
|
414
|
+
}
|
|
415
|
+
const token = authorization.slice("Bearer ".length).trim();
|
|
416
|
+
if (!token.startsWith("sk_") || token !== store.apiKey) {
|
|
417
|
+
return failure(
|
|
418
|
+
401,
|
|
419
|
+
"invalid_api_key",
|
|
420
|
+
"Missing credentials. Send Authorization: Bearer."
|
|
421
|
+
);
|
|
422
|
+
}
|
|
423
|
+
return null;
|
|
424
|
+
}
|
|
425
|
+
function readIdempotencyKey(headers) {
|
|
426
|
+
const raw = headerValue(headers, "idempotency-key");
|
|
427
|
+
const key = raw?.trim() ?? "";
|
|
428
|
+
if (!key) {
|
|
429
|
+
return failure(
|
|
430
|
+
400,
|
|
431
|
+
"invalid_request",
|
|
432
|
+
"Idempotency-Key header is required and must not be empty."
|
|
433
|
+
);
|
|
434
|
+
}
|
|
435
|
+
if (key.length > 255) {
|
|
436
|
+
return failure(
|
|
437
|
+
400,
|
|
438
|
+
"invalid_request",
|
|
439
|
+
"Idempotency-Key must not exceed 255 characters."
|
|
440
|
+
);
|
|
441
|
+
}
|
|
442
|
+
return { key };
|
|
443
|
+
}
|
|
444
|
+
function isTransitionAction(value) {
|
|
445
|
+
return value === "activate" || value === "reject_meta" || value === "set_spend" || value === "end";
|
|
446
|
+
}
|
|
447
|
+
var BUILT_IN_STRATEGIES = [
|
|
448
|
+
"maximum_growth",
|
|
449
|
+
"market_discovery",
|
|
450
|
+
"revenue_maximization"
|
|
451
|
+
];
|
|
452
|
+
var MIN_DAILY_BUDGET_USD = 10;
|
|
453
|
+
var DURATION_DAYS_MIN = 7;
|
|
454
|
+
var DURATION_DAYS_MAX_CUSTOM = 30;
|
|
455
|
+
var DURATION_DAYS_EXTRAS = /* @__PURE__ */ new Set([60, 90]);
|
|
456
|
+
function isValidDurationDays(durationDays) {
|
|
457
|
+
if (!Number.isInteger(durationDays)) {
|
|
458
|
+
return false;
|
|
459
|
+
}
|
|
460
|
+
if (DURATION_DAYS_EXTRAS.has(durationDays)) {
|
|
461
|
+
return true;
|
|
462
|
+
}
|
|
463
|
+
return durationDays >= DURATION_DAYS_MIN && durationDays <= DURATION_DAYS_MAX_CUSTOM;
|
|
464
|
+
}
|
|
465
|
+
function parseCreateBody(body) {
|
|
466
|
+
if (!body || typeof body !== "object") {
|
|
467
|
+
return {
|
|
468
|
+
ok: false,
|
|
469
|
+
status: 400,
|
|
470
|
+
code: "invalid_request",
|
|
471
|
+
message: "Invalid request body."
|
|
472
|
+
};
|
|
473
|
+
}
|
|
474
|
+
const raw = body;
|
|
475
|
+
if (typeof raw.spotifyUrl !== "string" || raw.spotifyUrl.length === 0) {
|
|
476
|
+
return {
|
|
477
|
+
ok: false,
|
|
478
|
+
status: 400,
|
|
479
|
+
code: "invalid_request",
|
|
480
|
+
message: "Missing required field: spotifyUrl."
|
|
481
|
+
};
|
|
482
|
+
}
|
|
483
|
+
if (typeof raw.dailyBudget !== "number") {
|
|
484
|
+
return {
|
|
485
|
+
ok: false,
|
|
486
|
+
status: 400,
|
|
487
|
+
code: "invalid_request",
|
|
488
|
+
message: "Missing required field: dailyBudget."
|
|
489
|
+
};
|
|
490
|
+
}
|
|
491
|
+
if (typeof raw.durationDays !== "number") {
|
|
492
|
+
return {
|
|
493
|
+
ok: false,
|
|
494
|
+
status: 400,
|
|
495
|
+
code: "invalid_request",
|
|
496
|
+
message: "Missing required field: durationDays."
|
|
497
|
+
};
|
|
498
|
+
}
|
|
499
|
+
if (typeof raw.genre !== "string" || raw.genre.length === 0) {
|
|
500
|
+
return {
|
|
501
|
+
ok: false,
|
|
502
|
+
status: 400,
|
|
503
|
+
code: "invalid_request",
|
|
504
|
+
message: "Missing required field: genre."
|
|
505
|
+
};
|
|
506
|
+
}
|
|
507
|
+
if (typeof raw.strategyType !== "string" || raw.strategyType.length === 0) {
|
|
508
|
+
return {
|
|
509
|
+
ok: false,
|
|
510
|
+
status: 400,
|
|
511
|
+
code: "invalid_request",
|
|
512
|
+
message: "Missing required field: strategyType."
|
|
513
|
+
};
|
|
514
|
+
}
|
|
515
|
+
if (!Number.isFinite(raw.dailyBudget) || raw.dailyBudget < MIN_DAILY_BUDGET_USD) {
|
|
516
|
+
return {
|
|
517
|
+
ok: false,
|
|
518
|
+
status: 422,
|
|
519
|
+
code: "invalid_daily_budget",
|
|
520
|
+
message: "dailyBudget must be at least 10 (USD per day)."
|
|
521
|
+
};
|
|
522
|
+
}
|
|
523
|
+
if (!Number.isFinite(raw.durationDays) || !isValidDurationDays(raw.durationDays)) {
|
|
524
|
+
return {
|
|
525
|
+
ok: false,
|
|
526
|
+
status: 422,
|
|
527
|
+
code: "invalid_duration_days",
|
|
528
|
+
message: "durationDays must be an integer from 7 to 30, or 60, or 90."
|
|
529
|
+
};
|
|
530
|
+
}
|
|
531
|
+
return { ok: true, value: body };
|
|
532
|
+
}
|
|
533
|
+
function dispatch(store, request) {
|
|
534
|
+
const method = request.method.toUpperCase();
|
|
535
|
+
const pathname = parsePathname(request.path);
|
|
536
|
+
if (pathname.startsWith("/__emulator")) {
|
|
537
|
+
return dispatchHarness(store, method, pathname, request.body);
|
|
538
|
+
}
|
|
539
|
+
if (!pathname.startsWith("/v1")) {
|
|
540
|
+
return failure(404, "not_found", "Not found.");
|
|
541
|
+
}
|
|
542
|
+
const authError = requireApiKey(store, request.headers);
|
|
543
|
+
if (authError) {
|
|
544
|
+
return authError;
|
|
545
|
+
}
|
|
546
|
+
if (method === "GET" && pathname === "/v1/ping") {
|
|
547
|
+
return success(200, { status: "ok" });
|
|
548
|
+
}
|
|
549
|
+
if (method === "GET" && pathname === "/v1/wallet") {
|
|
550
|
+
return success(200, store.getWallet());
|
|
551
|
+
}
|
|
552
|
+
if (method === "GET" && pathname === "/v1/strategies") {
|
|
553
|
+
return success(200, {
|
|
554
|
+
strategies: [
|
|
555
|
+
...BUILT_IN_STRATEGIES.map((strategyType) => ({
|
|
556
|
+
strategyType,
|
|
557
|
+
tierTargetingAllowed: false
|
|
558
|
+
})),
|
|
559
|
+
{ strategyType: "custom", tierTargetingAllowed: true }
|
|
560
|
+
]
|
|
561
|
+
});
|
|
562
|
+
}
|
|
563
|
+
if (method === "GET" && pathname === "/v1/campaigns") {
|
|
564
|
+
const items = store.listCampaigns().map((campaign) => {
|
|
565
|
+
const detail = store.toCampaignDetail(campaign);
|
|
566
|
+
return {
|
|
567
|
+
campaignId: detail.campaignId,
|
|
568
|
+
organizationId: detail.organizationId,
|
|
569
|
+
status: detail.status,
|
|
570
|
+
socialPlatform: detail.socialPlatform,
|
|
571
|
+
dailyBudget: detail.dailyBudget,
|
|
572
|
+
totalBudget: detail.totalBudget,
|
|
573
|
+
campaignDuration: detail.campaignDuration,
|
|
574
|
+
generation: detail.generation,
|
|
575
|
+
artistId: detail.artistId,
|
|
576
|
+
artistName: detail.artistName,
|
|
577
|
+
trackId: detail.trackId,
|
|
578
|
+
playlistId: detail.playlistId,
|
|
579
|
+
trackName: detail.trackName,
|
|
580
|
+
campaignUrl: detail.campaignUrl,
|
|
581
|
+
createdAt: detail.createdAt,
|
|
582
|
+
updatedAt: detail.updatedAt
|
|
583
|
+
};
|
|
584
|
+
});
|
|
585
|
+
return success(200, {
|
|
586
|
+
items,
|
|
587
|
+
pagination: {
|
|
588
|
+
page: 1,
|
|
589
|
+
pageSize: items.length || 20,
|
|
590
|
+
totalCount: items.length,
|
|
591
|
+
totalPages: 1
|
|
592
|
+
}
|
|
593
|
+
});
|
|
594
|
+
}
|
|
595
|
+
const campaignIdFromPath = matchPathGroup(pathname, /^\/v1\/campaigns\/([^/]+)$/);
|
|
596
|
+
if (method === "GET" && campaignIdFromPath) {
|
|
597
|
+
const campaign = store.getCampaign(decodeURIComponent(campaignIdFromPath));
|
|
598
|
+
if (!campaign) {
|
|
599
|
+
return failure(404, "campaign_not_found", "Campaign not found.");
|
|
600
|
+
}
|
|
601
|
+
return success(200, store.toCampaignDetail(campaign));
|
|
602
|
+
}
|
|
603
|
+
const overviewCampaignId = matchPathGroup(
|
|
604
|
+
pathname,
|
|
605
|
+
/^\/v1\/campaigns\/([^/]+)\/metrics\/overview$/
|
|
606
|
+
);
|
|
607
|
+
if (method === "GET" && overviewCampaignId) {
|
|
608
|
+
const campaign = store.getCampaign(decodeURIComponent(overviewCampaignId));
|
|
609
|
+
if (!campaign) {
|
|
610
|
+
return failure(404, "campaign_not_found", "Campaign not found.");
|
|
611
|
+
}
|
|
612
|
+
return success(200, store.buildOverview(campaign));
|
|
613
|
+
}
|
|
614
|
+
if (method === "POST" && pathname === "/v1/campaigns") {
|
|
615
|
+
return handleCreateCampaign(store, request);
|
|
616
|
+
}
|
|
617
|
+
const stopCampaignId = matchPathGroup(pathname, /^\/v1\/campaigns\/([^/]+)\/stop$/);
|
|
618
|
+
if (method === "POST" && stopCampaignId) {
|
|
619
|
+
return handleStopCampaign(store, decodeURIComponent(stopCampaignId), request);
|
|
620
|
+
}
|
|
621
|
+
return failure(404, "not_found", "Not found.");
|
|
622
|
+
}
|
|
623
|
+
function handleCreateCampaign(store, request) {
|
|
624
|
+
const idem = readIdempotencyKey(request.headers);
|
|
625
|
+
if ("status" in idem) {
|
|
626
|
+
return idem;
|
|
627
|
+
}
|
|
628
|
+
const parsed = parseCreateBody(request.body);
|
|
629
|
+
if (!parsed.ok) {
|
|
630
|
+
return failure(parsed.status, parsed.code, parsed.message);
|
|
631
|
+
}
|
|
632
|
+
const requestHash = hashPayload(parsed.value);
|
|
633
|
+
const existing = store.getIdempotency(idem.key);
|
|
634
|
+
if (existing) {
|
|
635
|
+
if (existing.requestHash !== requestHash) {
|
|
636
|
+
return failure(
|
|
637
|
+
409,
|
|
638
|
+
"idempotency_key_conflict",
|
|
639
|
+
"This Idempotency-Key was already used with a different request body."
|
|
640
|
+
);
|
|
641
|
+
}
|
|
642
|
+
return success(existing.status, existing.body);
|
|
643
|
+
}
|
|
644
|
+
const { dailyBudget, durationDays, autoRenew, strategyType, spotifyUrl, genre } = parsed.value;
|
|
645
|
+
const committedUsd = computeCommittedUsd(dailyBudget, durationDays);
|
|
646
|
+
const wallet = store.getWallet();
|
|
647
|
+
if (wallet.available < committedUsd) {
|
|
648
|
+
return failure(
|
|
649
|
+
402,
|
|
650
|
+
"insufficient_credit",
|
|
651
|
+
"Insufficient wallet balance for this campaign.",
|
|
652
|
+
{
|
|
653
|
+
available: wallet.available,
|
|
654
|
+
required: committedUsd
|
|
655
|
+
}
|
|
656
|
+
);
|
|
657
|
+
}
|
|
658
|
+
store.debitWallet(committedUsd);
|
|
659
|
+
const campaign = store.createCampaign({
|
|
660
|
+
dailyBudget,
|
|
661
|
+
durationDays,
|
|
662
|
+
autoRenew: autoRenew ?? false,
|
|
663
|
+
strategyType,
|
|
664
|
+
spotifyUrl,
|
|
665
|
+
genre,
|
|
666
|
+
campaignName: parsed.value.campaignName
|
|
667
|
+
});
|
|
668
|
+
const responseBody = {
|
|
669
|
+
campaignId: campaign.campaignId,
|
|
670
|
+
status: campaign.status,
|
|
671
|
+
autoRenew: campaign.autoRenew
|
|
672
|
+
};
|
|
673
|
+
store.setIdempotency(idem.key, {
|
|
674
|
+
requestHash,
|
|
675
|
+
status: 201,
|
|
676
|
+
body: responseBody
|
|
677
|
+
});
|
|
678
|
+
return success(201, responseBody);
|
|
679
|
+
}
|
|
680
|
+
function handleStopCampaign(store, campaignId, request) {
|
|
681
|
+
const idem = readIdempotencyKey(request.headers);
|
|
682
|
+
if ("status" in idem) {
|
|
683
|
+
return idem;
|
|
684
|
+
}
|
|
685
|
+
const campaign = store.getCampaign(campaignId);
|
|
686
|
+
if (!campaign) {
|
|
687
|
+
return failure(404, "campaign_not_found", "Campaign not found.");
|
|
688
|
+
}
|
|
689
|
+
const requestHash = hashPayload({ campaignId });
|
|
690
|
+
const existing = store.getIdempotency(idem.key);
|
|
691
|
+
if (existing) {
|
|
692
|
+
if (existing.requestHash !== requestHash) {
|
|
693
|
+
return failure(
|
|
694
|
+
409,
|
|
695
|
+
"idempotency_key_conflict",
|
|
696
|
+
"This Idempotency-Key was already used with a different request body."
|
|
697
|
+
);
|
|
698
|
+
}
|
|
699
|
+
return success(existing.status, existing.body);
|
|
700
|
+
}
|
|
701
|
+
const result = applyPublicStop(store, campaign);
|
|
702
|
+
if (result.releasedKey) {
|
|
703
|
+
store.deleteIdempotency(idem.key);
|
|
704
|
+
return failure(
|
|
705
|
+
400,
|
|
706
|
+
"invalid_request",
|
|
707
|
+
`Cannot stop campaign in status "${campaign.status}".`
|
|
708
|
+
);
|
|
709
|
+
}
|
|
710
|
+
const responseBody = {
|
|
711
|
+
campaignId: campaign.campaignId,
|
|
712
|
+
status: result.status
|
|
713
|
+
};
|
|
714
|
+
store.setIdempotency(idem.key, {
|
|
715
|
+
requestHash,
|
|
716
|
+
status: 200,
|
|
717
|
+
body: responseBody
|
|
718
|
+
});
|
|
719
|
+
return success(200, responseBody);
|
|
720
|
+
}
|
|
721
|
+
function dispatchHarness(store, method, pathname, body) {
|
|
722
|
+
if (method === "POST" && pathname === "/__emulator/reset") {
|
|
723
|
+
store.reset();
|
|
724
|
+
return success(200, { ok: true });
|
|
725
|
+
}
|
|
726
|
+
if (method === "POST" && pathname === "/__emulator/wallet") {
|
|
727
|
+
const balance = body && typeof body === "object" ? body.balance : void 0;
|
|
728
|
+
if (typeof balance !== "number" || !Number.isFinite(balance) || balance < 0) {
|
|
729
|
+
return failure(400, "invalid_request", "balance must be a non-negative number.");
|
|
730
|
+
}
|
|
731
|
+
return success(200, store.setWalletBalance(balance));
|
|
732
|
+
}
|
|
733
|
+
const harnessCampaignId = matchPathGroup(
|
|
734
|
+
pathname,
|
|
735
|
+
/^\/__emulator\/campaigns\/([^/]+)\/transition$/
|
|
736
|
+
);
|
|
737
|
+
if (method === "POST" && harnessCampaignId) {
|
|
738
|
+
const campaignId = decodeURIComponent(harnessCampaignId);
|
|
739
|
+
const action = body && typeof body === "object" ? body.action : void 0;
|
|
740
|
+
const mediaSpendUsd = body && typeof body === "object" ? body.mediaSpendUsd : void 0;
|
|
741
|
+
if (!isTransitionAction(action)) {
|
|
742
|
+
return failure(
|
|
743
|
+
400,
|
|
744
|
+
"invalid_request",
|
|
745
|
+
"action must be activate | reject_meta | set_spend | end."
|
|
746
|
+
);
|
|
747
|
+
}
|
|
748
|
+
try {
|
|
749
|
+
const result = applyTransition(
|
|
750
|
+
store,
|
|
751
|
+
campaignId,
|
|
752
|
+
action,
|
|
753
|
+
typeof mediaSpendUsd === "number" ? mediaSpendUsd : void 0
|
|
754
|
+
);
|
|
755
|
+
return success(200, result);
|
|
756
|
+
} catch (error) {
|
|
757
|
+
if (error instanceof TransitionError) {
|
|
758
|
+
return failure(error.status, error.code, error.message);
|
|
759
|
+
}
|
|
760
|
+
throw error;
|
|
761
|
+
}
|
|
762
|
+
}
|
|
763
|
+
return failure(404, "not_found", "Not found.");
|
|
764
|
+
}
|
|
765
|
+
|
|
766
|
+
// src/emulator/plans.ts
|
|
767
|
+
var EMULATOR_PLAN_PRESETS = {
|
|
768
|
+
free: { feeRate: 0.2, premium: false },
|
|
769
|
+
artist_pro: { feeRate: 0.2, premium: false },
|
|
770
|
+
studio: { feeRate: 0.2, premium: false },
|
|
771
|
+
label_power: { feeRate: 0.15, premium: true },
|
|
772
|
+
enterprise: { feeRate: 0.1, premium: true }
|
|
773
|
+
};
|
|
774
|
+
function resolveEmulatorPlan(options) {
|
|
775
|
+
const preset = options.plan ? EMULATOR_PLAN_PRESETS[options.plan] : null;
|
|
776
|
+
const feeRate = options.feeRate ?? preset?.feeRate ?? 0;
|
|
777
|
+
if (typeof feeRate !== "number" || !Number.isFinite(feeRate) || feeRate < 0 || feeRate >= 1) {
|
|
778
|
+
throw new Error("feeRate must be a finite number in [0, 1).");
|
|
779
|
+
}
|
|
780
|
+
return {
|
|
781
|
+
plan: options.plan ?? null,
|
|
782
|
+
feeRate,
|
|
783
|
+
premium: preset?.premium ?? true
|
|
784
|
+
};
|
|
785
|
+
}
|
|
786
|
+
var LOOPBACK_HOST = "127.0.0.1";
|
|
787
|
+
function normalizeHeaders(headers) {
|
|
788
|
+
const out = {};
|
|
789
|
+
for (const [key, value] of Object.entries(headers)) {
|
|
790
|
+
if (value === void 0) continue;
|
|
791
|
+
out[key] = Array.isArray(value) ? value[0] ?? "" : value;
|
|
792
|
+
}
|
|
793
|
+
return out;
|
|
794
|
+
}
|
|
795
|
+
async function readBody(req) {
|
|
796
|
+
const chunks = [];
|
|
797
|
+
for await (const chunk of req) {
|
|
798
|
+
if (typeof chunk === "string") {
|
|
799
|
+
chunks.push(Buffer.from(chunk));
|
|
800
|
+
} else if (chunk instanceof Uint8Array) {
|
|
801
|
+
chunks.push(Buffer.from(chunk));
|
|
802
|
+
}
|
|
803
|
+
}
|
|
804
|
+
if (chunks.length === 0) {
|
|
805
|
+
return void 0;
|
|
806
|
+
}
|
|
807
|
+
const raw = Buffer.concat(chunks).toString("utf8").trim();
|
|
808
|
+
if (raw.length === 0) {
|
|
809
|
+
return void 0;
|
|
810
|
+
}
|
|
811
|
+
try {
|
|
812
|
+
return JSON.parse(raw);
|
|
813
|
+
} catch {
|
|
814
|
+
return { __parseError: true, raw };
|
|
815
|
+
}
|
|
816
|
+
}
|
|
817
|
+
function listen(store, options = {}) {
|
|
818
|
+
const host = options.host ?? LOOPBACK_HOST;
|
|
819
|
+
if (host !== LOOPBACK_HOST) {
|
|
820
|
+
return Promise.reject(
|
|
821
|
+
new Error(`Emulator listen only allows host ${LOOPBACK_HOST} (got "${host}").`)
|
|
822
|
+
);
|
|
823
|
+
}
|
|
824
|
+
const port = options.port ?? 0;
|
|
825
|
+
return new Promise((resolve, reject) => {
|
|
826
|
+
const server = http.createServer((req, res) => {
|
|
827
|
+
void (async () => {
|
|
828
|
+
const method = req.method ?? "GET";
|
|
829
|
+
const path = req.url ?? "/";
|
|
830
|
+
const headers = normalizeHeaders(req.headers);
|
|
831
|
+
const body = await readBody(req);
|
|
832
|
+
if (body && typeof body === "object" && body.__parseError) {
|
|
833
|
+
res.writeHead(400, { "Content-Type": "application/json" });
|
|
834
|
+
res.end(
|
|
835
|
+
JSON.stringify({
|
|
836
|
+
error: {
|
|
837
|
+
code: "invalid_request",
|
|
838
|
+
message: "Request body must be valid JSON."
|
|
839
|
+
},
|
|
840
|
+
meta: { requestId: "emulator-invalid-json" }
|
|
841
|
+
})
|
|
842
|
+
);
|
|
843
|
+
return;
|
|
844
|
+
}
|
|
845
|
+
const response = dispatch(store, { method, path, headers, body });
|
|
846
|
+
res.writeHead(response.status, {
|
|
847
|
+
"Content-Type": "application/json"
|
|
848
|
+
});
|
|
849
|
+
res.end(JSON.stringify(response.json));
|
|
850
|
+
})().catch(() => {
|
|
851
|
+
res.writeHead(500, { "Content-Type": "application/json" });
|
|
852
|
+
res.end(
|
|
853
|
+
JSON.stringify({
|
|
854
|
+
error: {
|
|
855
|
+
code: "internal_error",
|
|
856
|
+
message: "Emulator request handler failed."
|
|
857
|
+
},
|
|
858
|
+
meta: { requestId: "emulator-internal" }
|
|
859
|
+
})
|
|
860
|
+
);
|
|
861
|
+
});
|
|
862
|
+
});
|
|
863
|
+
server.once("error", reject);
|
|
864
|
+
server.listen(port, host, () => {
|
|
865
|
+
const address = server.address();
|
|
866
|
+
if (!address || typeof address === "string") {
|
|
867
|
+
server.close();
|
|
868
|
+
reject(new Error("Failed to bind emulator server."));
|
|
869
|
+
return;
|
|
870
|
+
}
|
|
871
|
+
resolve({
|
|
872
|
+
host,
|
|
873
|
+
port: address.port,
|
|
874
|
+
baseUrl: `http://${host}:${String(address.port)}`,
|
|
875
|
+
close: () => new Promise((closeResolve, closeReject) => {
|
|
876
|
+
server.close((error) => {
|
|
877
|
+
if (error) {
|
|
878
|
+
closeReject(error);
|
|
879
|
+
return;
|
|
880
|
+
}
|
|
881
|
+
closeResolve();
|
|
882
|
+
});
|
|
883
|
+
})
|
|
884
|
+
});
|
|
885
|
+
});
|
|
886
|
+
});
|
|
887
|
+
}
|
|
888
|
+
|
|
889
|
+
// src/emulator/index.ts
|
|
890
|
+
function createApiEmulator(options = {}) {
|
|
891
|
+
const apiKey = options.apiKey ?? "sk_emulator_test";
|
|
892
|
+
if (!apiKey.startsWith("sk_")) {
|
|
893
|
+
throw new Error('apiKey must start with "sk_".');
|
|
894
|
+
}
|
|
895
|
+
const resolved = resolveEmulatorPlan({
|
|
896
|
+
plan: options.plan,
|
|
897
|
+
feeRate: options.feeRate
|
|
898
|
+
});
|
|
899
|
+
const store = createEmulatorStore({
|
|
900
|
+
apiKey,
|
|
901
|
+
initialWalletBalance: options.initialWalletBalance ?? 1e3,
|
|
902
|
+
feeRate: resolved.feeRate,
|
|
903
|
+
organizationId: options.organizationId
|
|
904
|
+
});
|
|
905
|
+
return {
|
|
906
|
+
dispatch(request) {
|
|
907
|
+
return dispatch(store, request);
|
|
908
|
+
},
|
|
909
|
+
listen(listenOptions) {
|
|
910
|
+
return listen(store, listenOptions);
|
|
911
|
+
},
|
|
912
|
+
reset() {
|
|
913
|
+
store.reset();
|
|
914
|
+
},
|
|
915
|
+
setWallet(balance) {
|
|
916
|
+
return store.setWalletBalance(balance);
|
|
917
|
+
},
|
|
918
|
+
transition(campaignId, action, mediaSpendUsd) {
|
|
919
|
+
return applyTransition(store, campaignId, action, mediaSpendUsd);
|
|
920
|
+
},
|
|
921
|
+
getWallet() {
|
|
922
|
+
return store.getWallet();
|
|
923
|
+
},
|
|
924
|
+
getPlan() {
|
|
925
|
+
return resolved;
|
|
926
|
+
}
|
|
927
|
+
};
|
|
928
|
+
}
|
|
929
|
+
|
|
930
|
+
exports.EMULATOR_PLAN_PRESETS = EMULATOR_PLAN_PRESETS;
|
|
931
|
+
exports.LOOPBACK_HOST = LOOPBACK_HOST;
|
|
932
|
+
exports.createApiEmulator = createApiEmulator;
|
|
933
|
+
//# sourceMappingURL=api-emulator.cjs.map
|
|
934
|
+
//# sourceMappingURL=api-emulator.cjs.map
|