@project-ajax/sdk 0.0.28

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.
Files changed (145) hide show
  1. package/README.md +22 -0
  2. package/dist/block.d.ts +321 -0
  3. package/dist/block.d.ts.map +1 -0
  4. package/dist/block.js +0 -0
  5. package/dist/builder.d.ts +12 -0
  6. package/dist/builder.d.ts.map +1 -0
  7. package/dist/builder.js +22 -0
  8. package/dist/capabilities/slashCommand.d.ts +56 -0
  9. package/dist/capabilities/slashCommand.d.ts.map +1 -0
  10. package/dist/capabilities/slashCommand.js +32 -0
  11. package/dist/capabilities/sync.d.ts +58 -0
  12. package/dist/capabilities/sync.d.ts.map +1 -0
  13. package/dist/capabilities/sync.js +26 -0
  14. package/dist/capabilities/tool.d.ts +69 -0
  15. package/dist/capabilities/tool.d.ts.map +1 -0
  16. package/dist/capabilities/tool.js +75 -0
  17. package/dist/capabilities/tool.test.d.ts +2 -0
  18. package/dist/capabilities/tool.test.d.ts.map +1 -0
  19. package/dist/cli/api/client.d.ts +185 -0
  20. package/dist/cli/api/client.d.ts.map +1 -0
  21. package/dist/cli/api/client.js +315 -0
  22. package/dist/cli/api/result.d.ts +43 -0
  23. package/dist/cli/api/result.d.ts.map +1 -0
  24. package/dist/cli/api/result.js +43 -0
  25. package/dist/cli/bin/cli.d.ts +3 -0
  26. package/dist/cli/bin/cli.d.ts.map +1 -0
  27. package/dist/cli/bin/cli.js +5 -0
  28. package/dist/cli/commands/auth.d.ts +2 -0
  29. package/dist/cli/commands/auth.d.ts.map +1 -0
  30. package/dist/cli/commands/auth.impl.d.ts +10 -0
  31. package/dist/cli/commands/auth.impl.d.ts.map +1 -0
  32. package/dist/cli/commands/auth.impl.js +68 -0
  33. package/dist/cli/commands/auth.js +71 -0
  34. package/dist/cli/commands/bundle.d.ts +2 -0
  35. package/dist/cli/commands/bundle.d.ts.map +1 -0
  36. package/dist/cli/commands/bundle.impl.d.ts +2 -0
  37. package/dist/cli/commands/bundle.impl.d.ts.map +1 -0
  38. package/dist/cli/commands/bundle.impl.js +21 -0
  39. package/dist/cli/commands/bundle.js +23 -0
  40. package/dist/cli/commands/capabilities.d.ts +2 -0
  41. package/dist/cli/commands/capabilities.d.ts.map +1 -0
  42. package/dist/cli/commands/capabilities.impl.d.ts +3 -0
  43. package/dist/cli/commands/capabilities.impl.d.ts.map +1 -0
  44. package/dist/cli/commands/capabilities.impl.js +40 -0
  45. package/dist/cli/commands/capabilities.js +24 -0
  46. package/dist/cli/commands/deploy.d.ts +3 -0
  47. package/dist/cli/commands/deploy.d.ts.map +1 -0
  48. package/dist/cli/commands/deploy.impl.d.ts +2 -0
  49. package/dist/cli/commands/deploy.impl.d.ts.map +1 -0
  50. package/dist/cli/commands/deploy.impl.js +31 -0
  51. package/dist/cli/commands/deploy.js +16 -0
  52. package/dist/cli/commands/exec.d.ts +3 -0
  53. package/dist/cli/commands/exec.d.ts.map +1 -0
  54. package/dist/cli/commands/exec.impl.d.ts +7 -0
  55. package/dist/cli/commands/exec.impl.d.ts.map +1 -0
  56. package/dist/cli/commands/exec.impl.js +122 -0
  57. package/dist/cli/commands/exec.js +30 -0
  58. package/dist/cli/commands/runs.d.ts +2 -0
  59. package/dist/cli/commands/runs.d.ts.map +1 -0
  60. package/dist/cli/commands/runs.impl.d.ts +4 -0
  61. package/dist/cli/commands/runs.impl.d.ts.map +1 -0
  62. package/dist/cli/commands/runs.impl.js +71 -0
  63. package/dist/cli/commands/runs.js +45 -0
  64. package/dist/cli/commands/secrets.d.ts +2 -0
  65. package/dist/cli/commands/secrets.d.ts.map +1 -0
  66. package/dist/cli/commands/secrets.impl.d.ts +5 -0
  67. package/dist/cli/commands/secrets.impl.d.ts.map +1 -0
  68. package/dist/cli/commands/secrets.impl.js +93 -0
  69. package/dist/cli/commands/secrets.js +64 -0
  70. package/dist/cli/config.d.ts +38 -0
  71. package/dist/cli/config.d.ts.map +1 -0
  72. package/dist/cli/config.js +133 -0
  73. package/dist/cli/context.d.ts +15 -0
  74. package/dist/cli/context.d.ts.map +1 -0
  75. package/dist/cli/context.js +16 -0
  76. package/dist/cli/deploy.d.ts +25 -0
  77. package/dist/cli/deploy.d.ts.map +1 -0
  78. package/dist/cli/deploy.js +101 -0
  79. package/dist/cli/flags.d.ts +16 -0
  80. package/dist/cli/flags.d.ts.map +1 -0
  81. package/dist/cli/flags.js +24 -0
  82. package/dist/cli/handler.d.ts +14 -0
  83. package/dist/cli/handler.d.ts.map +1 -0
  84. package/dist/cli/handler.js +30 -0
  85. package/dist/cli/routes.d.ts +2 -0
  86. package/dist/cli/routes.d.ts.map +1 -0
  87. package/dist/cli/routes.js +44 -0
  88. package/dist/cli/utils/array.d.ts +2 -0
  89. package/dist/cli/utils/array.d.ts.map +1 -0
  90. package/dist/cli/utils/array.js +10 -0
  91. package/dist/cli/utils/string.d.ts +2 -0
  92. package/dist/cli/utils/string.d.ts.map +1 -0
  93. package/dist/cli/utils/string.js +12 -0
  94. package/dist/cli/writer.d.ts +48 -0
  95. package/dist/cli/writer.d.ts.map +1 -0
  96. package/dist/cli/writer.js +73 -0
  97. package/dist/error.d.ts +8 -0
  98. package/dist/error.d.ts.map +1 -0
  99. package/dist/error.js +11 -0
  100. package/dist/index.d.ts +4 -0
  101. package/dist/index.d.ts.map +1 -0
  102. package/dist/index.js +8 -0
  103. package/dist/schema.d.ts +45 -0
  104. package/dist/schema.d.ts.map +1 -0
  105. package/dist/schema.js +14 -0
  106. package/dist/types.d.ts +11 -0
  107. package/dist/types.d.ts.map +1 -0
  108. package/dist/types.js +0 -0
  109. package/package.json +79 -0
  110. package/src/block.ts +529 -0
  111. package/src/builder.ts +26 -0
  112. package/src/capabilities/slashCommand.ts +71 -0
  113. package/src/capabilities/sync.ts +76 -0
  114. package/src/capabilities/tool.test.ts +181 -0
  115. package/src/capabilities/tool.ts +145 -0
  116. package/src/cli/api/client.ts +588 -0
  117. package/src/cli/api/result.ts +71 -0
  118. package/src/cli/bin/cli.ts +7 -0
  119. package/src/cli/commands/auth.impl.ts +92 -0
  120. package/src/cli/commands/auth.ts +77 -0
  121. package/src/cli/commands/bundle.impl.ts +21 -0
  122. package/src/cli/commands/bundle.ts +23 -0
  123. package/src/cli/commands/capabilities.impl.ts +47 -0
  124. package/src/cli/commands/capabilities.ts +25 -0
  125. package/src/cli/commands/deploy.impl.ts +34 -0
  126. package/src/cli/commands/deploy.ts +16 -0
  127. package/src/cli/commands/exec.impl.ts +169 -0
  128. package/src/cli/commands/exec.ts +32 -0
  129. package/src/cli/commands/runs.impl.ts +87 -0
  130. package/src/cli/commands/runs.ts +49 -0
  131. package/src/cli/commands/secrets.impl.ts +124 -0
  132. package/src/cli/commands/secrets.ts +73 -0
  133. package/src/cli/config.ts +175 -0
  134. package/src/cli/context.ts +26 -0
  135. package/src/cli/deploy.ts +175 -0
  136. package/src/cli/flags.ts +43 -0
  137. package/src/cli/handler.ts +62 -0
  138. package/src/cli/routes.ts +43 -0
  139. package/src/cli/utils/array.ts +7 -0
  140. package/src/cli/utils/string.ts +9 -0
  141. package/src/cli/writer.ts +97 -0
  142. package/src/error.ts +12 -0
  143. package/src/index.ts +3 -0
  144. package/src/schema.ts +54 -0
  145. package/src/types.ts +10 -0
@@ -0,0 +1,43 @@
1
+ import { buildApplication, buildRouteMap, text_en } from "@stricli/core";
2
+ import packageJson from "../../package.json" with { type: "json" };
3
+ import { authCommands } from "./commands/auth.js";
4
+ import { bundleCommands } from "./commands/bundle.js";
5
+ import { capabilitiesCommands } from "./commands/capabilities.js";
6
+ import deploy from "./commands/deploy.js";
7
+ import exec from "./commands/exec.js";
8
+ import { runsCommands } from "./commands/runs.js";
9
+ import { secretsCommands } from "./commands/secrets.js";
10
+ import { TokenNotSetError } from "./config.js";
11
+
12
+ const routes = buildRouteMap({
13
+ docs: {
14
+ brief: "A CLI for the Project Ajax platform",
15
+ },
16
+ routes: {
17
+ auth: authCommands,
18
+ capabilities: capabilitiesCommands,
19
+ deploy: deploy,
20
+ exec: exec,
21
+ runs: runsCommands,
22
+ secrets: secretsCommands,
23
+ bundle: bundleCommands,
24
+ },
25
+ });
26
+
27
+ export const app = buildApplication(routes, {
28
+ name: "workers",
29
+ versionInfo: {
30
+ currentVersion: packageJson.version,
31
+ },
32
+ localization: {
33
+ loadText: () => ({
34
+ ...text_en,
35
+ exceptionWhileRunningCommand(exc: unknown, ansiColor: boolean): string {
36
+ if (exc instanceof TokenNotSetError) {
37
+ return exc.message;
38
+ }
39
+ return text_en.exceptionWhileRunningCommand(exc, ansiColor);
40
+ },
41
+ }),
42
+ },
43
+ });
@@ -0,0 +1,7 @@
1
+ export function chunkEvery<T>(array: readonly T[], size: number): T[][] {
2
+ const result: T[][] = [];
3
+ for (let i = 0; i < array.length; i += size) {
4
+ result.push(array.slice(i, i + size));
5
+ }
6
+ return result;
7
+ }
@@ -0,0 +1,9 @@
1
+ export function pluralize(count: number, word: string, pluralWord?: string) {
2
+ if (count === 1) {
3
+ return `${count} ${word}`;
4
+ }
5
+ if (!pluralWord) {
6
+ return `${count} ${word}s`;
7
+ }
8
+ return `${count} ${pluralWord}`;
9
+ }
@@ -0,0 +1,97 @@
1
+ import { createTable, type TableCell, type TableItem } from "@visulima/tabular";
2
+
3
+ export interface WriterOptions {
4
+ debugEnabled: boolean;
5
+ }
6
+
7
+ export interface TableOptions {
8
+ headers: TableCell[] | TableCell[][];
9
+ rows: TableCell[][];
10
+ plain: boolean;
11
+ }
12
+
13
+ /**
14
+ * A writer writes messages to standard out and standard error.
15
+ */
16
+ export class Writer {
17
+ debugEnabled: boolean;
18
+
19
+ constructor(options: WriterOptions) {
20
+ this.debugEnabled = options.debugEnabled;
21
+ }
22
+
23
+ /**
24
+ * Writes a debug message to standard error.
25
+ *
26
+ * @param args The arguments to write.
27
+ */
28
+ debug(...args: Parameters<typeof console.log>) {
29
+ if (this.debugEnabled) {
30
+ args
31
+ .join(" ")
32
+ .split("\n")
33
+ .forEach((line) => {
34
+ this.writeErr(`[debug] ${line}`);
35
+ });
36
+ }
37
+ }
38
+
39
+ /**
40
+ * Writes a message to standard out.
41
+ *
42
+ * @param args The arguments to write.
43
+ */
44
+ writeOut(...args: Parameters<typeof process.stdout.write>) {
45
+ process.stdout.write(`${args.join(" ")}\n`);
46
+ }
47
+
48
+ /**
49
+ * Writes a message to standard error.
50
+ *
51
+ * @param args The arguments to write.
52
+ */
53
+ writeErr(...args: Parameters<typeof process.stderr.write>) {
54
+ process.stderr.write(`${args.join(" ")}\n`);
55
+ }
56
+
57
+ /**
58
+ * Writes a table to standard out.
59
+ *
60
+ * @param tableConfig The table configuration.
61
+ */
62
+ writeTableOut(tableConfig: TableOptions) {
63
+ const content = this.#buildTable(tableConfig);
64
+ this.writeOut(content);
65
+ }
66
+
67
+ /**
68
+ * Writes a table to standard error.
69
+ *
70
+ * @param tableConfig The table configuration.
71
+ */
72
+ writeTableErr(tableConfig: TableOptions) {
73
+ const content = this.#buildTable(tableConfig);
74
+ this.writeErr(content);
75
+ }
76
+
77
+ #buildTable(tableConfig: TableOptions) {
78
+ if (tableConfig.plain) {
79
+ return tableConfig.rows
80
+ .map((row) => {
81
+ return row
82
+ .map((cell) => (isTableItem(cell) ? cell.content : cell))
83
+ .join("\t");
84
+ })
85
+ .join("\n");
86
+ } else {
87
+ const table = createTable();
88
+ table.setHeaders(tableConfig.headers);
89
+ table.addRows(...tableConfig.rows);
90
+ return table.toString();
91
+ }
92
+ }
93
+ }
94
+
95
+ function isTableItem(cell: TableCell): cell is TableItem {
96
+ return typeof cell === "object";
97
+ }
package/src/error.ts ADDED
@@ -0,0 +1,12 @@
1
+ /**
2
+ * An error that occurred during the execution of a sync.
3
+ */
4
+ export class ExecutionError extends Error {
5
+ readonly cause: unknown;
6
+
7
+ constructor(cause: unknown) {
8
+ super(`Error during sync execution: ${cause}`);
9
+ this.name = "ExecutionError";
10
+ this.cause = cause;
11
+ }
12
+ }
package/src/index.ts ADDED
@@ -0,0 +1,3 @@
1
+ export { slashCommand } from "./capabilities/slashCommand.js";
2
+ export { sync } from "./capabilities/sync.js";
3
+ export { tool } from "./capabilities/tool.js";
package/src/schema.ts ADDED
@@ -0,0 +1,54 @@
1
+ /**
2
+ * Supported property types for sync schemas.
3
+ */
4
+ export type PropertyType = "title" | "rich_text" | "url";
5
+
6
+ /**
7
+ * Definition of a single property in a sync schema.
8
+ */
9
+ export type PropertyDefinition = {
10
+ type: PropertyType;
11
+ };
12
+
13
+ /**
14
+ * A schema defining the structure a single property in a data source.
15
+ */
16
+ export type PropertyConfiguration =
17
+ | { type: "title" }
18
+ | { type: "text" }
19
+ | { type: "url" };
20
+
21
+ export type Schema<PK extends string> = {
22
+ dataSourceTitle: string;
23
+ properties: PropertySchema<PK>;
24
+ };
25
+
26
+ /**
27
+ * A schema defining the structure of properties in a data source.
28
+ */
29
+ export type PropertySchema<PK extends string> = {
30
+ [PrimaryKey in PK]: PropertyConfiguration;
31
+ } & {
32
+ [propertyName: string]: PropertyConfiguration;
33
+ };
34
+
35
+ /**
36
+ * Creates a title property definition.
37
+ */
38
+ export function title(): PropertyConfiguration {
39
+ return { type: "title" };
40
+ }
41
+
42
+ /**
43
+ * Creates a rich text property definition.
44
+ */
45
+ export function richText(): PropertyConfiguration {
46
+ return { type: "text" };
47
+ }
48
+
49
+ /**
50
+ * Creates a URL property definition.
51
+ */
52
+ export function url(): PropertyConfiguration {
53
+ return { type: "url" };
54
+ }
package/src/types.ts ADDED
@@ -0,0 +1,10 @@
1
+ /**
2
+ * A text token is a tuple where the first element is the text content
3
+ * and optional subsequent elements are formatting annotations.
4
+ */
5
+ type TextToken = [string, ...unknown[]];
6
+
7
+ /**
8
+ * A TextValue is an array of text tokens, representing rich text content.
9
+ */
10
+ export type TextValue = Array<TextToken>;