@usesocial/cli 0.17.0 → 0.18.1
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 +12 -0
- package/dist/index.mjs +185 -8
- package/dist/index.mjs.map +1 -1
- package/package.json +1 -1
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,17 @@
|
|
|
1
1
|
# @usesocial/cli
|
|
2
2
|
|
|
3
|
+
## 0.18.1
|
|
4
|
+
|
|
5
|
+
### Patch Changes
|
|
6
|
+
|
|
7
|
+
- [#98](https://github.com/usesocial/monorepo/pull/98) [`ec79564`](https://github.com/usesocial/monorepo/commit/ec79564b1840edb08721357a6d9416afeab6350e) Thanks [@CyrusNuevoDia](https://github.com/CyrusNuevoDia)! - Mark LinkedIn chats read after sending a message.
|
|
8
|
+
|
|
9
|
+
## 0.18.0
|
|
10
|
+
|
|
11
|
+
### Minor Changes
|
|
12
|
+
|
|
13
|
+
- [#94](https://github.com/usesocial/monorepo/pull/94) [`ab46b97`](https://github.com/usesocial/monorepo/commit/ab46b97d452c698d8314981758acd75ebaba1e83) Thanks [@CyrusNuevoDia](https://github.com/CyrusNuevoDia)! - Add stdin-only Poke integration connect and disconnect commands for LinkedIn message delivery.
|
|
14
|
+
|
|
3
15
|
## 0.17.0
|
|
4
16
|
|
|
5
17
|
### Minor Changes
|
package/dist/index.mjs
CHANGED
|
@@ -454,7 +454,7 @@ const productBrand = {
|
|
|
454
454
|
const brand = {
|
|
455
455
|
org,
|
|
456
456
|
name: productBrand.name,
|
|
457
|
-
tagline: "
|
|
457
|
+
tagline: "Agentic founder-led distribution",
|
|
458
458
|
description: productBrand.description
|
|
459
459
|
};
|
|
460
460
|
const brandURLs = {
|
|
@@ -10933,6 +10933,31 @@ const WRAPPED_STATUSES = [
|
|
|
10933
10933
|
"done",
|
|
10934
10934
|
"failed"
|
|
10935
10935
|
];
|
|
10936
|
+
const WEBHOOK_CONNECTION_STATUSES = [
|
|
10937
|
+
"connecting",
|
|
10938
|
+
"connected",
|
|
10939
|
+
"dormant",
|
|
10940
|
+
"disconnecting",
|
|
10941
|
+
"disconnected",
|
|
10942
|
+
"error"
|
|
10943
|
+
];
|
|
10944
|
+
const WEBHOOK_SUBSCRIPTION_STATUSES = [
|
|
10945
|
+
"provisioning",
|
|
10946
|
+
"active",
|
|
10947
|
+
"deleting",
|
|
10948
|
+
"deleted",
|
|
10949
|
+
"create_failed",
|
|
10950
|
+
"delete_failed"
|
|
10951
|
+
];
|
|
10952
|
+
const WEBHOOK_OPERATION_KINDS = ["create", "delete"];
|
|
10953
|
+
const WEBHOOK_OPERATION_STATES = [
|
|
10954
|
+
"intended",
|
|
10955
|
+
"adopted",
|
|
10956
|
+
"completed",
|
|
10957
|
+
"outcome_unknown",
|
|
10958
|
+
"create_failed",
|
|
10959
|
+
"delete_failed"
|
|
10960
|
+
];
|
|
10936
10961
|
_enum(PLATFORMS);
|
|
10937
10962
|
_enum(CONNECTED_ACCOUNT_STATUSES);
|
|
10938
10963
|
_enum(PROXY_SURFACES);
|
|
@@ -10942,6 +10967,10 @@ _enum(CLI_SCOPE_ALIASES$1);
|
|
|
10942
10967
|
_enum(CLI_CAPABILITIES);
|
|
10943
10968
|
_enum(FEEDBACK_TYPES);
|
|
10944
10969
|
_enum(WRAPPED_STATUSES);
|
|
10970
|
+
_enum(WEBHOOK_CONNECTION_STATUSES);
|
|
10971
|
+
_enum(WEBHOOK_SUBSCRIPTION_STATUSES);
|
|
10972
|
+
_enum(WEBHOOK_OPERATION_KINDS);
|
|
10973
|
+
_enum(WEBHOOK_OPERATION_STATES);
|
|
10945
10974
|
string().trim().min(1).transform((email) => email.toLowerCase()).brand();
|
|
10946
10975
|
union([number(), string().trim().min(1)]).transform((value) => Number(value)).pipe(number().int().nonnegative()).brand();
|
|
10947
10976
|
h("InvalidBillingOverrideEmail")();
|
|
@@ -11150,6 +11179,69 @@ pgTable("account_defaults", {
|
|
|
11150
11179
|
index("account_defaults_connected_account_idx").on(table.connectedAccountId),
|
|
11151
11180
|
check("account_defaults_platform_check", sqlCheckIn(table.platform, PLATFORMS))
|
|
11152
11181
|
]);
|
|
11182
|
+
const webhookConnections = pgTable("webhook_connections", {
|
|
11183
|
+
id: text$1("id").primaryKey().$defaultFn(() => crypto.randomUUID()),
|
|
11184
|
+
userId: text$1("user_id").notNull().references(() => user.id),
|
|
11185
|
+
integration: text$1("integration").notNull(),
|
|
11186
|
+
destination: text$1("destination").notNull(),
|
|
11187
|
+
destinationConfigCiphertext: text$1("destination_config_ciphertext").notNull(),
|
|
11188
|
+
generation: integer("generation").notNull().default(1),
|
|
11189
|
+
status: text$1("status", { enum: WEBHOOK_CONNECTION_STATUSES }).notNull().default("connecting"),
|
|
11190
|
+
lastErrorCode: text$1("last_error_code"),
|
|
11191
|
+
createdAt: timestamptz("created_at").notNull().defaultNow(),
|
|
11192
|
+
updatedAt: timestamptz("updated_at").notNull().defaultNow().$onUpdate(() => /* @__PURE__ */ new Date())
|
|
11193
|
+
}, (table) => [
|
|
11194
|
+
uniqueIndex("webhook_connections_user_integration_key").on(table.userId, table.integration),
|
|
11195
|
+
index("webhook_connections_status_idx").on(table.status, table.updatedAt),
|
|
11196
|
+
check("webhook_connections_generation_check", sql`${table.generation} > 0`),
|
|
11197
|
+
check("webhook_connections_status_check", sqlCheckIn(table.status, WEBHOOK_CONNECTION_STATUSES))
|
|
11198
|
+
]);
|
|
11199
|
+
const webhookSubscriptions = pgTable("webhook_subscriptions", {
|
|
11200
|
+
id: text$1("id").primaryKey().$defaultFn(() => crypto.randomUUID()),
|
|
11201
|
+
connectionId: text$1("connection_id").notNull().references(() => webhookConnections.id),
|
|
11202
|
+
source: text$1("source").notNull(),
|
|
11203
|
+
sourceAccountId: text$1("source_account_id").notNull(),
|
|
11204
|
+
providerSourceAccountId: text$1("provider_source_account_id").notNull(),
|
|
11205
|
+
providerVisibleUID: text$1("provider_visible_uid").notNull(),
|
|
11206
|
+
remoteSubscriptionId: text$1("remote_subscription_id"),
|
|
11207
|
+
signingSecretCiphertext: text$1("signing_secret_ciphertext"),
|
|
11208
|
+
ingressId: text$1("ingress_id").notNull(),
|
|
11209
|
+
generation: integer("generation").notNull(),
|
|
11210
|
+
status: text$1("status", { enum: WEBHOOK_SUBSCRIPTION_STATUSES }).notNull().default("provisioning"),
|
|
11211
|
+
lastErrorCode: text$1("last_error_code"),
|
|
11212
|
+
createdAt: timestamptz("created_at").notNull().defaultNow(),
|
|
11213
|
+
updatedAt: timestamptz("updated_at").notNull().defaultNow().$onUpdate(() => /* @__PURE__ */ new Date())
|
|
11214
|
+
}, (table) => [
|
|
11215
|
+
uniqueIndex("webhook_subscriptions_connection_source_account_key").on(table.connectionId, table.source, table.sourceAccountId),
|
|
11216
|
+
uniqueIndex("webhook_subscriptions_source_visible_uid_key").on(table.source, table.providerVisibleUID),
|
|
11217
|
+
uniqueIndex("webhook_subscriptions_ingress_id_key").on(table.ingressId),
|
|
11218
|
+
index("webhook_subscriptions_connection_status_idx").on(table.connectionId, table.status, table.updatedAt),
|
|
11219
|
+
check("webhook_subscriptions_generation_check", sql`${table.generation} > 0`),
|
|
11220
|
+
check("webhook_subscriptions_status_check", sqlCheckIn(table.status, WEBHOOK_SUBSCRIPTION_STATUSES))
|
|
11221
|
+
]);
|
|
11222
|
+
pgTable("webhook_operations", {
|
|
11223
|
+
id: text$1("id").primaryKey().$defaultFn(() => crypto.randomUUID()),
|
|
11224
|
+
connectionId: text$1("connection_id").notNull().references(() => webhookConnections.id),
|
|
11225
|
+
subscriptionId: text$1("subscription_id").references(() => webhookSubscriptions.id),
|
|
11226
|
+
provider: text$1("provider").notNull(),
|
|
11227
|
+
kind: text$1("kind", { enum: WEBHOOK_OPERATION_KINDS }).notNull(),
|
|
11228
|
+
providerVisibleUID: text$1("provider_visible_uid").notNull(),
|
|
11229
|
+
remoteResourceId: text$1("remote_resource_id"),
|
|
11230
|
+
generation: integer("generation").notNull(),
|
|
11231
|
+
state: text$1("state", { enum: WEBHOOK_OPERATION_STATES }).notNull().default("intended"),
|
|
11232
|
+
attemptCount: integer("attempt_count").notNull().default(0),
|
|
11233
|
+
lastErrorCode: text$1("last_error_code"),
|
|
11234
|
+
createdAt: timestamptz("created_at").notNull().defaultNow(),
|
|
11235
|
+
updatedAt: timestamptz("updated_at").notNull().defaultNow().$onUpdate(() => /* @__PURE__ */ new Date())
|
|
11236
|
+
}, (table) => [
|
|
11237
|
+
uniqueIndex("webhook_operations_provider_kind_uid_key").on(table.provider, table.kind, table.providerVisibleUID),
|
|
11238
|
+
index("webhook_operations_connection_state_idx").on(table.connectionId, table.state, table.updatedAt),
|
|
11239
|
+
index("webhook_operations_subscription_idx").on(table.subscriptionId),
|
|
11240
|
+
check("webhook_operations_generation_check", sql`${table.generation} > 0`),
|
|
11241
|
+
check("webhook_operations_attempt_count_check", sql`${table.attemptCount} >= 0`),
|
|
11242
|
+
check("webhook_operations_kind_check", sqlCheckIn(table.kind, WEBHOOK_OPERATION_KINDS)),
|
|
11243
|
+
check("webhook_operations_state_check", sqlCheckIn(table.state, WEBHOOK_OPERATION_STATES))
|
|
11244
|
+
]);
|
|
11153
11245
|
pgTable("billing_overrides", {
|
|
11154
11246
|
email: text$1("email").primaryKey(),
|
|
11155
11247
|
userId: text$1("user_id").references(() => user.id, { onDelete: "cascade" }),
|
|
@@ -15585,6 +15677,16 @@ const buildSql$1 = (deps, platform) => defineCommand({
|
|
|
15585
15677
|
}
|
|
15586
15678
|
}
|
|
15587
15679
|
});
|
|
15680
|
+
const patchChatReadStatus = async (deps, chatId, headers, read) => {
|
|
15681
|
+
const response = await deps.api.patch("linkedin/chats/".concat(encodeURIComponent(chatId)), {
|
|
15682
|
+
headers,
|
|
15683
|
+
json: { read_status: read }
|
|
15684
|
+
});
|
|
15685
|
+
return {
|
|
15686
|
+
data: await response.json(),
|
|
15687
|
+
response
|
|
15688
|
+
};
|
|
15689
|
+
};
|
|
15588
15690
|
const buildMark = (deps) => {
|
|
15589
15691
|
const schemaContract = {
|
|
15590
15692
|
inputSchema: schemas$1.MessagesMarkInput,
|
|
@@ -15675,11 +15777,7 @@ const buildMark = (deps) => {
|
|
|
15675
15777
|
});
|
|
15676
15778
|
const accountIdHeader = selectedAccount.selector;
|
|
15677
15779
|
const headers = { ...accountIdHeader === void 0 ? {} : { "x-social-account-id": accountIdHeader } };
|
|
15678
|
-
const response = await deps.
|
|
15679
|
-
headers,
|
|
15680
|
-
json: { read_status: input.status === "read" }
|
|
15681
|
-
});
|
|
15682
|
-
const data = await response.json();
|
|
15780
|
+
const { data, response } = await patchChatReadStatus(deps, chat_id, headers, input.status === "read");
|
|
15683
15781
|
await deps.printResult({
|
|
15684
15782
|
account: selectedAccount,
|
|
15685
15783
|
contract: schemaContractFrom(cmd),
|
|
@@ -16194,6 +16292,7 @@ const buildMessage$1 = (deps, sendCommand) => {
|
|
|
16194
16292
|
const data = await response.json();
|
|
16195
16293
|
const messageId = responseStringOrFirst(data, ["message_id"]);
|
|
16196
16294
|
const chatId = classified.kind === "thread" ? classified.id : responseString$1(data, ["chat_id", "id"]);
|
|
16295
|
+
if (responseSucceeded$1(response) && chatId !== void 0) await patchChatReadStatus(deps, chatId, headers, true);
|
|
16197
16296
|
if (responseSucceeded$1(response) && messageId !== void 0 && chatId !== void 0) {
|
|
16198
16297
|
const ownAccountId = requireAccountSelector$1(own.accountIdHeader);
|
|
16199
16298
|
writeThroughLinkedinCache({
|
|
@@ -24173,7 +24272,7 @@ function createEnv(opts) {
|
|
|
24173
24272
|
}
|
|
24174
24273
|
//#endregion
|
|
24175
24274
|
//#region package.json
|
|
24176
|
-
var version$1 = "0.
|
|
24275
|
+
var version$1 = "0.18.1";
|
|
24177
24276
|
//#endregion
|
|
24178
24277
|
//#region src/lib/env.ts
|
|
24179
24278
|
const URLWithTrailingSlash = url().transform(ensureTrailingSlash);
|
|
@@ -33622,6 +33721,78 @@ const createFeedbackCommand = (deps) => defineCommand({
|
|
|
33622
33721
|
}
|
|
33623
33722
|
});
|
|
33624
33723
|
//#endregion
|
|
33724
|
+
//#region src/integration/index.ts
|
|
33725
|
+
const pokeContract = writeCLIContract({
|
|
33726
|
+
outputSchema: object({
|
|
33727
|
+
integration: literal("poke"),
|
|
33728
|
+
status: _enum([
|
|
33729
|
+
"connected",
|
|
33730
|
+
"disconnected",
|
|
33731
|
+
"dormant"
|
|
33732
|
+
]),
|
|
33733
|
+
subscriptions: number().int().nonnegative()
|
|
33734
|
+
}),
|
|
33735
|
+
hazards: [{
|
|
33736
|
+
code: "integration_lifecycle",
|
|
33737
|
+
message: "Changes the Poke integration."
|
|
33738
|
+
}]
|
|
33739
|
+
});
|
|
33740
|
+
const readPokeAPIKey = async (deps) => {
|
|
33741
|
+
if (deps.isStdinTTY()) throw new UsageError("No Poke API key. Pipe it via stdin: `printf %s \"$POKE_API_KEY\" | social integration connect poke`.");
|
|
33742
|
+
const apiKey = trimTrailingNewline(await deps.readStdin());
|
|
33743
|
+
if (apiKey.length === 0) throw new UsageError("The piped Poke API key is empty.");
|
|
33744
|
+
return apiKey;
|
|
33745
|
+
};
|
|
33746
|
+
const rejectAccountFlag = (rawArgs) => {
|
|
33747
|
+
if (rawArgs.some((arg) => arg === "--account" || arg.startsWith("--account="))) throw new UsageError("--account is not supported for Poke integrations.");
|
|
33748
|
+
};
|
|
33749
|
+
const createIntegrationCommand = (deps) => defineCommand({
|
|
33750
|
+
meta: {
|
|
33751
|
+
name: "integration",
|
|
33752
|
+
description: "Manage external integrations."
|
|
33753
|
+
},
|
|
33754
|
+
subCommands: {
|
|
33755
|
+
connect: defineCommand({
|
|
33756
|
+
meta: {
|
|
33757
|
+
name: "connect",
|
|
33758
|
+
description: "Connect an integration."
|
|
33759
|
+
},
|
|
33760
|
+
subCommands: { poke: defineCommand({
|
|
33761
|
+
meta: commandMeta({
|
|
33762
|
+
name: "poke",
|
|
33763
|
+
description: "Connect Poke using an API key piped through stdin [write]",
|
|
33764
|
+
capability: "write",
|
|
33765
|
+
contract: pokeContract,
|
|
33766
|
+
stdin: true
|
|
33767
|
+
}),
|
|
33768
|
+
run: async ({ rawArgs }) => {
|
|
33769
|
+
rejectAccountFlag(rawArgs);
|
|
33770
|
+
const apiKey = await readPokeAPIKey(deps);
|
|
33771
|
+
deps.printData(await deps.client.poke.connect({ apiKey }));
|
|
33772
|
+
}
|
|
33773
|
+
}) }
|
|
33774
|
+
}),
|
|
33775
|
+
disconnect: defineCommand({
|
|
33776
|
+
meta: {
|
|
33777
|
+
name: "disconnect",
|
|
33778
|
+
description: "Disconnect an integration."
|
|
33779
|
+
},
|
|
33780
|
+
subCommands: { poke: defineCommand({
|
|
33781
|
+
meta: commandMeta({
|
|
33782
|
+
name: "poke",
|
|
33783
|
+
description: "Disconnect Poke [write]",
|
|
33784
|
+
capability: "write",
|
|
33785
|
+
contract: pokeContract
|
|
33786
|
+
}),
|
|
33787
|
+
run: async ({ rawArgs }) => {
|
|
33788
|
+
rejectAccountFlag(rawArgs);
|
|
33789
|
+
deps.printData(await deps.client.poke.disconnect({}));
|
|
33790
|
+
}
|
|
33791
|
+
}) }
|
|
33792
|
+
})
|
|
33793
|
+
}
|
|
33794
|
+
});
|
|
33795
|
+
//#endregion
|
|
33625
33796
|
//#region src/lib/account.ts
|
|
33626
33797
|
const LEADING_AT_PATTERN = /^@+/;
|
|
33627
33798
|
const normalizeAccountIdentifier = (value) => value.trim().replace(LEADING_AT_PATTERN, "").toLowerCase();
|
|
@@ -38770,7 +38941,11 @@ const createCLIDeps = () => {
|
|
|
38770
38941
|
summary: client.usage.summary,
|
|
38771
38942
|
list: client.usage.list
|
|
38772
38943
|
},
|
|
38773
|
-
feedback: { submit: client.feedback.submit }
|
|
38944
|
+
feedback: { submit: client.feedback.submit },
|
|
38945
|
+
poke: {
|
|
38946
|
+
connect: client.integrations.poke.connect,
|
|
38947
|
+
disconnect: client.integrations.poke.disconnect
|
|
38948
|
+
}
|
|
38774
38949
|
},
|
|
38775
38950
|
api,
|
|
38776
38951
|
parseResourceId,
|
|
@@ -40089,6 +40264,7 @@ const createSocialCommand = (deps = createCLIDeps()) => {
|
|
|
40089
40264
|
const linkedinCommand = asMutableCommand(createLinkedinCommands(deps));
|
|
40090
40265
|
const xCommand = asMutableCommand(createXCommands(deps));
|
|
40091
40266
|
const feedbackCommand = asMutableCommand(createFeedbackCommand(deps));
|
|
40267
|
+
const integrationCommand = asMutableCommand(createIntegrationCommand(deps));
|
|
40092
40268
|
const socialCommand = defineCommand({
|
|
40093
40269
|
meta: {
|
|
40094
40270
|
name: "social",
|
|
@@ -40102,6 +40278,7 @@ const createSocialCommand = (deps = createCLIDeps()) => {
|
|
|
40102
40278
|
x: xCommand,
|
|
40103
40279
|
linkedin: linkedinCommand,
|
|
40104
40280
|
feedback: feedbackCommand,
|
|
40281
|
+
integration: integrationCommand,
|
|
40105
40282
|
mcp: mcpCommand
|
|
40106
40283
|
}
|
|
40107
40284
|
});
|