@erdoai/cli 0.109.0 → 0.110.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/index.js +48 -11
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -1,5 +1,18 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
2
|
|
|
3
|
+
// src/ads-container.ts
|
|
4
|
+
function advertiserVerificationAction(container) {
|
|
5
|
+
const verification = container.advertiser_verification;
|
|
6
|
+
if (!verification || verification.action_url) return void 0;
|
|
7
|
+
if (verification.status === "check_in_google_ads") {
|
|
8
|
+
return `Google cannot expose advertiser verification for card-billed account ${container.customer_id} through the API. Open Billing \u2192 Advertiser verification in Google Ads to check its status, and complete verification there only if Google shows it is pending.`;
|
|
9
|
+
}
|
|
10
|
+
if (verification.status === "PENDING_USER_ACTION" || verification.status === "FAILURE") {
|
|
11
|
+
return `Google shows no business name or logo on ${container.customer_id}'s ads until the advertiser is verified. Get a link with: erdo org managed ads-container ${container.org_slug} --provision --start-verification`;
|
|
12
|
+
}
|
|
13
|
+
return void 0;
|
|
14
|
+
}
|
|
15
|
+
|
|
3
16
|
// src/refresh.ts
|
|
4
17
|
function describeRefreshTrigger(state) {
|
|
5
18
|
if (state.disarmed) return "disarmed \u2014 the experiment has settled";
|
|
@@ -1128,6 +1141,11 @@ var ErdoClient = class {
|
|
|
1128
1141
|
const qs = q.toString();
|
|
1129
1142
|
return this.request("GET", `/v1/datasets-purposes${qs ? `?${qs}` : ""}`);
|
|
1130
1143
|
}
|
|
1144
|
+
// Create an empty dataset with its declared columns. The server refuses a
|
|
1145
|
+
// create without a schema unless the purpose's columns are platform-defined.
|
|
1146
|
+
createDataset(input) {
|
|
1147
|
+
return this.request("POST", "/v1/datasets-create", input);
|
|
1148
|
+
}
|
|
1131
1149
|
ensureDataset(input) {
|
|
1132
1150
|
return this.request("POST", "/v1/datasets-ensure", input);
|
|
1133
1151
|
}
|
|
@@ -2724,12 +2742,9 @@ function printAdsContainer(c) {
|
|
|
2724
2742
|
console.log(`advertiser verification: ${v.status}`);
|
|
2725
2743
|
if (v.action_url) console.log(`verification link: ${v.action_url}`);
|
|
2726
2744
|
if (v.completion_deadline) console.log(`verification deadline: ${v.completion_deadline}`);
|
|
2727
|
-
|
|
2728
|
-
|
|
2729
|
-
|
|
2730
|
-
`
|
|
2731
|
-
);
|
|
2732
|
-
}
|
|
2745
|
+
const action = advertiserVerificationAction(c);
|
|
2746
|
+
if (action) process.stderr.write(`${action}
|
|
2747
|
+
`);
|
|
2733
2748
|
}
|
|
2734
2749
|
}
|
|
2735
2750
|
managed.command("ads-container <orgSlug>").description(
|
|
@@ -6492,15 +6507,37 @@ datasetsCmd.command("purposes").description(
|
|
|
6492
6507
|
fail(e);
|
|
6493
6508
|
}
|
|
6494
6509
|
});
|
|
6510
|
+
function readSchemaFile(path) {
|
|
6511
|
+
const parsed = JSON.parse(readFileSync4(path, "utf8"));
|
|
6512
|
+
const schema = Array.isArray(parsed) ? { columns: parsed } : parsed;
|
|
6513
|
+
if (!schema || !Array.isArray(schema.columns)) {
|
|
6514
|
+
throw new Error('--schema must contain a JSON columns array or {"columns": [...]} object');
|
|
6515
|
+
}
|
|
6516
|
+
return schema;
|
|
6517
|
+
}
|
|
6518
|
+
datasetsCmd.command("create <name>").description(
|
|
6519
|
+
"Create an empty dataset with its columns declared up front. Every write is checked against the schema, which is set now rather than taken from the first rows. --schema is required unless the purpose is one whose columns Erdo defines (page events, widget events, widget leads)."
|
|
6520
|
+
).option("--schema <file>", "JSON file containing { columns: [...] } or a columns array").option("--purpose <purpose>", "the dataset's role in the org vocabulary, e.g. leads (see `erdo datasets purposes`)").option("--purpose-description <text>", "what writes and reads this purpose").option("--description <text>", "what the dataset holds").option("--separate", "deliberately create a second dataset for a purpose the org already has").action(async (name, opts) => {
|
|
6521
|
+
try {
|
|
6522
|
+
const result = await new ErdoClient().createDataset({
|
|
6523
|
+
name,
|
|
6524
|
+
...opts.schema ? { schema: readSchemaFile(opts.schema) } : {},
|
|
6525
|
+
...opts.purpose ? { purpose: opts.purpose } : {},
|
|
6526
|
+
...opts.purposeDescription ? { purpose_description: opts.purposeDescription } : {},
|
|
6527
|
+
...opts.description ? { description: opts.description } : {},
|
|
6528
|
+
...opts.separate ? { separate_dataset: true } : {}
|
|
6529
|
+
});
|
|
6530
|
+
console.log(`${result.slug} created${result.purpose ? ` ${result.purpose}` : ""}`);
|
|
6531
|
+
for (const warning of result.warnings ?? []) console.error(`warning: ${warning}`);
|
|
6532
|
+
} catch (e) {
|
|
6533
|
+
fail(e);
|
|
6534
|
+
}
|
|
6535
|
+
});
|
|
6495
6536
|
datasetsCmd.command("ensure <purpose>").description(
|
|
6496
6537
|
"Create or reuse the one dataset for a purpose and verify its declared producer contract. Refuses legacy splits and incompatible populated datasets instead of choosing silently."
|
|
6497
6538
|
).requiredOption("--schema <file>", "JSON file containing { columns: [...] } or a columns array").option("--name <name>", "dataset name when creation is required").option("--description <text>", "dataset description when creation is required").option("--purpose-description <text>", "what writes and reads this purpose").option("--preferred-dataset <slug>", "existing bound dataset slug or id to adopt").option("--email-column <name>", "for a leads purpose: which declared column holds the email (default email)").option("--phone-column <name>", "for a leads purpose: which declared column holds the phone (default phone)").action(async (purpose, opts) => {
|
|
6498
6539
|
try {
|
|
6499
|
-
const
|
|
6500
|
-
const declaredSchema = Array.isArray(parsed) ? { columns: parsed } : parsed;
|
|
6501
|
-
if (!declaredSchema || !Array.isArray(declaredSchema.columns)) {
|
|
6502
|
-
throw new Error('--schema must contain a JSON columns array or {"columns": [...]} object');
|
|
6503
|
-
}
|
|
6540
|
+
const declaredSchema = readSchemaFile(opts.schema);
|
|
6504
6541
|
const result = await new ErdoClient().ensureDataset({
|
|
6505
6542
|
purpose,
|
|
6506
6543
|
...opts.name ? { name: opts.name } : {},
|