@pipelab/plugin-discord 1.0.0-beta.14 → 1.0.0-beta.15

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.mjs CHANGED
@@ -4,11 +4,11 @@ import { basename, join, normalize } from "path";
4
4
  import { formatWithOptions, types } from "util";
5
5
  import path$1, { basename as basename$1, delimiter, dirname, join as join$1, sep } from "node:path";
6
6
  import { fileURLToPath } from "node:url";
7
- import { constants, tmpdir } from "node:os";
7
+ import { constants } from "node:os";
8
8
  import { appendFileSync, createReadStream, createWriteStream, existsSync, readFileSync, readdirSync, statSync, writeFileSync } from "node:fs";
9
+ import { access, chmod, cp, mkdir, readFile, readdir, rename, rm, writeFile } from "node:fs/promises";
9
10
  import http from "node:http";
10
11
  import { webcrypto } from "node:crypto";
11
- import { access, chmod, cp, mkdir, mkdtemp, readFile, readdir, realpath, rename, rm, writeFile } from "node:fs/promises";
12
12
  import { ChildProcess, execFile, spawn, spawnSync } from "node:child_process";
13
13
  import { StringDecoder } from "node:string_decoder";
14
14
  import { aborted, callbackify, debuglog, formatWithOptions as formatWithOptions$1, inspect, promisify, stripVTControlCharacters } from "node:util";
@@ -1597,6 +1597,56 @@ function literal(literal_, message) {
1597
1597
  }
1598
1598
  };
1599
1599
  }
1600
+ function looseObject(entries, message) {
1601
+ return {
1602
+ kind: "schema",
1603
+ type: "loose_object",
1604
+ reference: looseObject,
1605
+ expects: "Object",
1606
+ async: false,
1607
+ entries,
1608
+ message,
1609
+ _run(dataset, config2) {
1610
+ const input = dataset.value;
1611
+ if (input && typeof input === "object") {
1612
+ dataset.typed = true;
1613
+ dataset.value = {};
1614
+ for (const key in this.entries) {
1615
+ const value2 = input[key];
1616
+ const valueDataset = this.entries[key]._run({
1617
+ typed: false,
1618
+ value: value2
1619
+ }, config2);
1620
+ if (valueDataset.issues) {
1621
+ const pathItem = {
1622
+ type: "object",
1623
+ origin: "value",
1624
+ input,
1625
+ key,
1626
+ value: value2
1627
+ };
1628
+ for (const issue of valueDataset.issues) {
1629
+ if (issue.path) issue.path.unshift(pathItem);
1630
+ else issue.path = [pathItem];
1631
+ dataset.issues?.push(issue);
1632
+ }
1633
+ if (!dataset.issues) dataset.issues = valueDataset.issues;
1634
+ if (config2.abortEarly) {
1635
+ dataset.typed = false;
1636
+ break;
1637
+ }
1638
+ }
1639
+ if (!valueDataset.typed) dataset.typed = false;
1640
+ if (valueDataset.value !== void 0 || key in input) dataset.value[key] = valueDataset.value;
1641
+ }
1642
+ if (!dataset.issues || !config2.abortEarly) {
1643
+ for (const key in input) if (_isValidObjectKey(input, key) && !(key in this.entries)) dataset.value[key] = input[key];
1644
+ }
1645
+ } else _addIssue(this, "type", dataset, config2);
1646
+ return dataset;
1647
+ }
1648
+ };
1649
+ }
1600
1650
  function number(message) {
1601
1651
  return {
1602
1652
  kind: "schema",
@@ -2134,6 +2184,18 @@ settingsMigratorInternal.createMigrations({
2134
2184
  })
2135
2185
  ]
2136
2186
  });
2187
+ const connectionsMigratorInternal = createMigrator();
2188
+ const defaultConnections = connectionsMigratorInternal.createDefault({
2189
+ version: "1.0.0",
2190
+ connections: []
2191
+ });
2192
+ connectionsMigratorInternal.createMigrations({
2193
+ defaultValue: defaultConnections,
2194
+ migrations: [createMigration({
2195
+ version: "1.0.0",
2196
+ up: finalVersion
2197
+ })]
2198
+ });
2137
2199
  const fileRepoMigratorInternal = createMigrator();
2138
2200
  const defaultFileRepo = fileRepoMigratorInternal.createDefault({
2139
2201
  version: "2.0.0",
@@ -2295,11 +2357,51 @@ const LEGACY_ID_MAP = {
2295
2357
  };
2296
2358
  const getStrictPluginId = (pluginId) => {
2297
2359
  if (!pluginId) return pluginId;
2298
- if (LEGACY_ID_MAP[pluginId]) return LEGACY_ID_MAP[pluginId];
2299
- if (pluginId.startsWith("@") || pluginId.includes("/") || pluginId.startsWith("pipelab-plugin-")) return pluginId;
2300
- const prefixed = `@pipelab/plugin-${pluginId}`;
2301
- return LEGACY_ID_MAP[prefixed] || prefixed;
2360
+ return LEGACY_ID_MAP[pluginId] || pluginId;
2302
2361
  };
2362
+ //#endregion
2363
+ //#region ../../packages/shared/src/save-location.ts
2364
+ const SaveLocationInternalValidator = object({
2365
+ id: string(),
2366
+ project: string(),
2367
+ lastModified: string(),
2368
+ type: literal("internal"),
2369
+ configName: string()
2370
+ });
2371
+ const SaveLocationValidator = union([
2372
+ object({
2373
+ id: string(),
2374
+ project: string(),
2375
+ path: string(),
2376
+ lastModified: string(),
2377
+ type: literal("external"),
2378
+ summary: object({
2379
+ plugins: array(string()),
2380
+ name: string(),
2381
+ description: string()
2382
+ })
2383
+ }),
2384
+ SaveLocationInternalValidator,
2385
+ object({
2386
+ id: string(),
2387
+ project: string(),
2388
+ type: literal("pipelab-cloud")
2389
+ })
2390
+ ]);
2391
+ object({
2392
+ version: literal("1.0.0"),
2393
+ data: optional(record(string(), SaveLocationValidator), {})
2394
+ });
2395
+ const FileRepoProjectValidatorV2$1 = object({
2396
+ id: string(),
2397
+ name: string(),
2398
+ description: string()
2399
+ });
2400
+ object({
2401
+ version: literal("2.0.0"),
2402
+ projects: array(FileRepoProjectValidatorV2$1),
2403
+ pipelines: optional(array(SaveLocationValidator), [])
2404
+ });
2303
2405
  object({
2304
2406
  cacheFolder: string(),
2305
2407
  theme: union([literal("light"), literal("dark")]),
@@ -2451,6 +2553,17 @@ object({
2451
2553
  })),
2452
2554
  isInternalMigrationBannerClosed: optional(boolean(), false)
2453
2555
  });
2556
+ const ConnectionValidator = looseObject({
2557
+ id: string(),
2558
+ pluginName: string(),
2559
+ name: string(),
2560
+ createdAt: string(),
2561
+ isDefault: boolean()
2562
+ });
2563
+ object({
2564
+ version: literal("1.0.0"),
2565
+ connections: array(ConnectionValidator)
2566
+ });
2454
2567
  //#endregion
2455
2568
  //#region ../../node_modules/tslog/dist/esm/prettyLogStyles.js
2456
2569
  const prettyLogStyles = {
@@ -2971,7 +3084,7 @@ const useLogger = () => {
2971
3084
  const OriginValidator = object({
2972
3085
  pluginId: string(),
2973
3086
  nodeId: string(),
2974
- version: pipe(optional(string()), description("Pinned version of the plugin for this block. Falls back to \"latest\" when absent."))
3087
+ version: optional(pipe(string(), description("Pinned version of the plugin for this block. Falls back to \"latest\" when absent.")))
2975
3088
  });
2976
3089
  const BlockActionValidatorV1 = object({
2977
3090
  type: literal("action"),
@@ -2984,7 +3097,7 @@ const EditorParamValidatorV3 = union([literal("simple"), literal("editor")]);
2984
3097
  const BlockActionValidatorV3 = object({
2985
3098
  type: literal("action"),
2986
3099
  uid: string(),
2987
- name: pipe(optional(string()), description("A custom name provided by the user")),
3100
+ name: optional(pipe(string(), description("A custom name provided by the user"))),
2988
3101
  disabled: optional(boolean()),
2989
3102
  params: record(string(), object({
2990
3103
  editor: EditorParamValidatorV3,
@@ -45284,35 +45397,6 @@ const createPathParam = (value, definition) => {
45284
45397
  };
45285
45398
  };
45286
45399
  //#endregion
45287
- //#region ../../packages/shared/src/save-location.ts
45288
- const SaveLocationInternalValidator = object({
45289
- id: string(),
45290
- project: string(),
45291
- lastModified: string(),
45292
- type: literal("internal"),
45293
- configName: string()
45294
- });
45295
- const SaveLocationValidator = union([
45296
- object({
45297
- id: string(),
45298
- project: string(),
45299
- path: string(),
45300
- lastModified: string(),
45301
- type: literal("external"),
45302
- summary: object({
45303
- plugins: array(string()),
45304
- name: string(),
45305
- description: string()
45306
- })
45307
- }),
45308
- SaveLocationInternalValidator,
45309
- object({
45310
- id: string(),
45311
- project: string(),
45312
- type: literal("pipelab-cloud")
45313
- })
45314
- ]);
45315
- //#endregion
45316
45400
  //#region ../../packages/shared/src/websocket.types.ts
45317
45401
  var WebSocketError = class extends Error {
45318
45402
  constructor(message, code, requestId) {
@@ -45329,20 +45413,6 @@ object({
45329
45413
  version: literal("1.0.0"),
45330
45414
  data: optional(record(string(), SaveLocationValidator), {})
45331
45415
  });
45332
- const FileRepoProjectValidatorV2$1 = object({
45333
- id: string(),
45334
- name: string(),
45335
- description: string()
45336
- });
45337
- object({
45338
- version: literal("2.0.0"),
45339
- projects: array(FileRepoProjectValidatorV2$1),
45340
- pipelines: optional(array(SaveLocationValidator), [])
45341
- });
45342
- object({
45343
- version: literal("1.0.0"),
45344
- data: optional(record(string(), SaveLocationValidator), {})
45345
- });
45346
45416
  const FileRepoProjectValidatorV2 = object({
45347
45417
  id: string(),
45348
45418
  name: string(),
@@ -45362,9 +45432,15 @@ var init_esm_shims = __esmMin((() => {
45362
45432
  __dirname = /* @__PURE__ */ getDirname();
45363
45433
  }));
45364
45434
  //#endregion
45365
- //#region ../../packages/core-node/src/context.ts
45435
+ //#region ../../packages/constants/src/index.ts
45366
45436
  init_esm_shims();
45367
- const _dirname = typeof __dirname !== "undefined" ? __dirname : typeof import.meta !== "undefined" && import.meta.url ? dirname(fileURLToPath(import.meta.url)) : process.cwd();
45437
+ const websocketPort = 33753;
45438
+ const DEFAULT_NODE_VERSION = "24.14.1";
45439
+ const DEFAULT_PNPM_VERSION = "10.12.0";
45440
+ //#endregion
45441
+ //#region ../../packages/core-node/src/context.ts
45442
+ const metaUrl = typeof import.meta !== "undefined" ? import.meta.url : void 0;
45443
+ const _dirname = typeof __dirname !== "undefined" ? __dirname : metaUrl ? dirname(fileURLToPath(metaUrl)) : process.cwd();
45368
45444
  const isDev = process.env.NODE_ENV === "development";
45369
45445
  /**
45370
45446
  * Finds the monorepo root by looking for pnpm-workspace.yaml.
@@ -48936,9 +49012,6 @@ const useAPI = () => {
48936
49012
  };
48937
49013
  };
48938
49014
  //#endregion
48939
- //#region ../../packages/constants/src/index.ts
48940
- const websocketPort = 33753;
48941
- //#endregion
48942
49015
  //#region ../../packages/core-node/src/websocket-server.ts
48943
49016
  var WebSocketServer = class {
48944
49017
  wss = null;
@@ -89343,14 +89416,6 @@ var import_tar = /* @__PURE__ */ __toESM(require_tar$1(), 1);
89343
89416
  var import_yauzl = /* @__PURE__ */ __toESM(require_yauzl(), 1);
89344
89417
  require_archiver();
89345
89418
  /**
89346
- * Generates a unique temporary folder.
89347
- */
89348
- const generateTempFolder = async (base) => {
89349
- const targetBase = base || tmpdir();
89350
- await mkdir(targetBase, { recursive: true });
89351
- return await mkdtemp(join$1(await realpath(targetBase), "pipelab-"));
89352
- };
89353
- /**
89354
89419
  * Extracts a .tar.gz archive.
89355
89420
  */
89356
89421
  async function extractTarGz(archivePath, destinationDir) {
@@ -100901,11 +100966,11 @@ var require_cp = /* @__PURE__ */ __commonJSMin(((exports, module) => {
100901
100966
  var require_with_temp_dir = /* @__PURE__ */ __commonJSMin(((exports, module) => {
100902
100967
  const { join: join$6, sep: sep$2 } = __require("path");
100903
100968
  const getOptions = require_get_options();
100904
- const { mkdir: mkdir$4, mkdtemp: mkdtemp$1, rm: rm$5 } = __require("fs/promises");
100969
+ const { mkdir: mkdir$4, mkdtemp, rm: rm$5 } = __require("fs/promises");
100905
100970
  const withTempDir = async (root, fn, opts) => {
100906
100971
  const options = getOptions(opts, { copy: ["tmpPrefix"] });
100907
100972
  await mkdir$4(root, { recursive: true });
100908
- const target = await mkdtemp$1(join$6(`${root}${sep$2}`, options.tmpPrefix || ""));
100973
+ const target = await mkdtemp(join$6(`${root}${sep$2}`, options.tmpPrefix || ""));
100909
100974
  let err;
100910
100975
  let result;
100911
100976
  try {
@@ -150579,7 +150644,7 @@ var require_error = /* @__PURE__ */ __commonJSMin(((exports, module) => {
150579
150644
  const { promisify: promisify$1 } = __require("util");
150580
150645
  const path = __require("path");
150581
150646
  const { createHash } = __require("crypto");
150582
- const { realpath: realpath$1, lstat, createReadStream: createReadStream$1, readdir: readdir$1 } = __require("fs");
150647
+ const { realpath, lstat, createReadStream: createReadStream$1, readdir: readdir$1 } = __require("fs");
150583
150648
  const url = __require("url");
150584
150649
  const slasher = require_glob_slash();
150585
150650
  const minimatch = require_minimatch();
@@ -150902,7 +150967,7 @@ var require_error = /* @__PURE__ */ __commonJSMin(((exports, module) => {
150902
150967
  };
150903
150968
  const getHandlers = (methods) => Object.assign({
150904
150969
  lstat: promisify$1(lstat),
150905
- realpath: promisify$1(realpath$1),
150970
+ realpath: promisify$1(realpath),
150906
150971
  createReadStream: createReadStream$1,
150907
150972
  readdir: promisify$1(readdir$1),
150908
150973
  sendError
@@ -151041,8 +151106,6 @@ const sendStartupProgress = (message) => {
151041
151106
  };
151042
151107
  //#endregion
151043
151108
  //#region ../../packages/core-node/src/utils/remote.ts
151044
- const DEFAULT_NODE_VERSION = "24.14.1";
151045
- const DEFAULT_PNPM_VERSION = "10.12.0";
151046
151109
  function isPackageComplete(packageDir) {
151047
151110
  return existsSync(join$1(packageDir, "package.json"));
151048
151111
  }
@@ -151234,7 +151297,7 @@ async function ensureNodeJS(context, version = DEFAULT_NODE_VERSION) {
151234
151297
  const extension = isWindows ? "zip" : "tar.gz";
151235
151298
  const fileName = `node-v${version}-${platform === "osx" ? "darwin" : platform}-${arch}.${extension}`;
151236
151299
  const downloadUrl = `https://nodejs.org/dist/v${version}/${fileName}`;
151237
- const tempDir = await generateTempFolder(tmpdir());
151300
+ const tempDir = await context.createTempFolder("node-download-");
151238
151301
  const archivePath = join$1(tempDir, fileName);
151239
151302
  sendStartupProgress(`Downloading Node.js v${version}...`);
151240
151303
  console.log(`Downloading Node.js from ${downloadUrl}...`);
@@ -152743,13 +152806,24 @@ const packageV2Runner = createActionRunner(async ({ inputs, cwd, paths, log, set
152743
152806
  });
152744
152807
  //#endregion
152745
152808
  //#region src/index.ts
152746
- var src_default = createNodeDefinition({ nodes: [{
152747
- node: createPackageProps(IDPackage, "Package as Discord Activity", "Package your app as a Discord Activity", "", "`Package app from ${fmt.param(params['input-folder'], 'primary', 'Input folder not set')}`", false, false, void 0, false, false),
152748
- runner: packageV2Runner
152749
- }, {
152750
- node: createPreviewProps(IDPreview, "Preview Discord Acitivity app", "Package and preview your app as a Discord Activity", "", "`Preview app from ${fmt.param(params['input-folder'], 'primary', 'Input folder not set')}`"),
152751
- runner: previewRunner
152752
- }] });
152809
+ var src_default = createNodeDefinition({
152810
+ nodes: [{
152811
+ node: createPackageProps(IDPackage, "Package as Discord Activity", "Package your app as a Discord Activity", "", "`Package app from ${fmt.param(params['input-folder'], 'primary', 'Input folder not set')}`", false, false, void 0, false, false),
152812
+ runner: packageV2Runner
152813
+ }, {
152814
+ node: createPreviewProps(IDPreview, "Preview Discord Acitivity app", "Package and preview your app as a Discord Activity", "", "`Preview app from ${fmt.param(params['input-folder'], 'primary', 'Input folder not set')}`"),
152815
+ runner: previewRunner
152816
+ }],
152817
+ integrations: [{
152818
+ name: "Discord Connection",
152819
+ fields: [{
152820
+ key: "apiKey",
152821
+ label: "Webhook URL",
152822
+ type: "text",
152823
+ placeholder: "https://discord.com/api/webhooks/..."
152824
+ }]
152825
+ }]
152826
+ });
152753
152827
  //#endregion
152754
152828
  export { src_default as default };
152755
152829