@usesocial/cli 0.17.0 → 0.18.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 CHANGED
@@ -1,5 +1,11 @@
1
1
  # @usesocial/cli
2
2
 
3
+ ## 0.18.0
4
+
5
+ ### Minor Changes
6
+
7
+ - [#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.
8
+
3
9
  ## 0.17.0
4
10
 
5
11
  ### Minor Changes
package/dist/index.mjs CHANGED
@@ -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" }),
@@ -24173,7 +24265,7 @@ function createEnv(opts) {
24173
24265
  }
24174
24266
  //#endregion
24175
24267
  //#region package.json
24176
- var version$1 = "0.17.0";
24268
+ var version$1 = "0.18.0";
24177
24269
  //#endregion
24178
24270
  //#region src/lib/env.ts
24179
24271
  const URLWithTrailingSlash = url().transform(ensureTrailingSlash);
@@ -33622,6 +33714,78 @@ const createFeedbackCommand = (deps) => defineCommand({
33622
33714
  }
33623
33715
  });
33624
33716
  //#endregion
33717
+ //#region src/integration/index.ts
33718
+ const pokeContract = writeCLIContract({
33719
+ outputSchema: object({
33720
+ integration: literal("poke"),
33721
+ status: _enum([
33722
+ "connected",
33723
+ "disconnected",
33724
+ "dormant"
33725
+ ]),
33726
+ subscriptions: number().int().nonnegative()
33727
+ }),
33728
+ hazards: [{
33729
+ code: "integration_lifecycle",
33730
+ message: "Changes the Poke integration."
33731
+ }]
33732
+ });
33733
+ const readPokeAPIKey = async (deps) => {
33734
+ if (deps.isStdinTTY()) throw new UsageError("No Poke API key. Pipe it via stdin: `printf %s \"$POKE_API_KEY\" | social integration connect poke`.");
33735
+ const apiKey = trimTrailingNewline(await deps.readStdin());
33736
+ if (apiKey.length === 0) throw new UsageError("The piped Poke API key is empty.");
33737
+ return apiKey;
33738
+ };
33739
+ const rejectAccountFlag = (rawArgs) => {
33740
+ if (rawArgs.some((arg) => arg === "--account" || arg.startsWith("--account="))) throw new UsageError("--account is not supported for Poke integrations.");
33741
+ };
33742
+ const createIntegrationCommand = (deps) => defineCommand({
33743
+ meta: {
33744
+ name: "integration",
33745
+ description: "Manage external integrations."
33746
+ },
33747
+ subCommands: {
33748
+ connect: defineCommand({
33749
+ meta: {
33750
+ name: "connect",
33751
+ description: "Connect an integration."
33752
+ },
33753
+ subCommands: { poke: defineCommand({
33754
+ meta: commandMeta({
33755
+ name: "poke",
33756
+ description: "Connect Poke using an API key piped through stdin [write]",
33757
+ capability: "write",
33758
+ contract: pokeContract,
33759
+ stdin: true
33760
+ }),
33761
+ run: async ({ rawArgs }) => {
33762
+ rejectAccountFlag(rawArgs);
33763
+ const apiKey = await readPokeAPIKey(deps);
33764
+ deps.printData(await deps.client.poke.connect({ apiKey }));
33765
+ }
33766
+ }) }
33767
+ }),
33768
+ disconnect: defineCommand({
33769
+ meta: {
33770
+ name: "disconnect",
33771
+ description: "Disconnect an integration."
33772
+ },
33773
+ subCommands: { poke: defineCommand({
33774
+ meta: commandMeta({
33775
+ name: "poke",
33776
+ description: "Disconnect Poke [write]",
33777
+ capability: "write",
33778
+ contract: pokeContract
33779
+ }),
33780
+ run: async ({ rawArgs }) => {
33781
+ rejectAccountFlag(rawArgs);
33782
+ deps.printData(await deps.client.poke.disconnect({}));
33783
+ }
33784
+ }) }
33785
+ })
33786
+ }
33787
+ });
33788
+ //#endregion
33625
33789
  //#region src/lib/account.ts
33626
33790
  const LEADING_AT_PATTERN = /^@+/;
33627
33791
  const normalizeAccountIdentifier = (value) => value.trim().replace(LEADING_AT_PATTERN, "").toLowerCase();
@@ -38770,7 +38934,11 @@ const createCLIDeps = () => {
38770
38934
  summary: client.usage.summary,
38771
38935
  list: client.usage.list
38772
38936
  },
38773
- feedback: { submit: client.feedback.submit }
38937
+ feedback: { submit: client.feedback.submit },
38938
+ poke: {
38939
+ connect: client.integrations.poke.connect,
38940
+ disconnect: client.integrations.poke.disconnect
38941
+ }
38774
38942
  },
38775
38943
  api,
38776
38944
  parseResourceId,
@@ -40089,6 +40257,7 @@ const createSocialCommand = (deps = createCLIDeps()) => {
40089
40257
  const linkedinCommand = asMutableCommand(createLinkedinCommands(deps));
40090
40258
  const xCommand = asMutableCommand(createXCommands(deps));
40091
40259
  const feedbackCommand = asMutableCommand(createFeedbackCommand(deps));
40260
+ const integrationCommand = asMutableCommand(createIntegrationCommand(deps));
40092
40261
  const socialCommand = defineCommand({
40093
40262
  meta: {
40094
40263
  name: "social",
@@ -40102,6 +40271,7 @@ const createSocialCommand = (deps = createCLIDeps()) => {
40102
40271
  x: xCommand,
40103
40272
  linkedin: linkedinCommand,
40104
40273
  feedback: feedbackCommand,
40274
+ integration: integrationCommand,
40105
40275
  mcp: mcpCommand
40106
40276
  }
40107
40277
  });