@mekari-officeless/sdk 0.1.0 → 1.0.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/package.json CHANGED
@@ -1,19 +1,74 @@
1
1
  {
2
2
  "name": "@mekari-officeless/sdk",
3
+ "version": "1.0.0",
4
+ "description": "Officeless SDK — run Officeless automations and sign users in from the browser.",
5
+ "license": "UNLICENSED",
3
6
  "private": false,
7
+ "type": "module",
8
+ "sideEffects": false,
9
+ "exports": {
10
+ ".": {
11
+ "import": {
12
+ "types": "./dist/index.d.ts",
13
+ "default": "./dist/index.js"
14
+ },
15
+ "require": {
16
+ "types": "./dist/index.d.cts",
17
+ "default": "./dist/index.cjs"
18
+ }
19
+ },
20
+ "./package.json": "./package.json"
21
+ },
22
+ "main": "./dist/index.cjs",
23
+ "module": "./dist/index.js",
24
+ "types": "./dist/index.d.ts",
25
+ "files": [
26
+ "dist",
27
+ "README.md",
28
+ "CHANGELOG.md"
29
+ ],
4
30
  "publishConfig": {
5
31
  "access": "public"
6
32
  },
7
- "version": "0.1.0",
8
- "description": "Official Officeless SDK for JS frontends",
9
- "type": "module",
10
- "main": "src/index.js",
11
- "exports": {
12
- ".": "./src/index.js"
33
+ "devDependencies": {
34
+ "@eslint/js": "^9.39.0",
35
+ "@vitest/browser": "^4.1.11",
36
+ "@vitest/browser-playwright": "^4.1.11",
37
+ "@vitest/coverage-v8": "^4.1.11",
38
+ "eslint": "^9.39.0",
39
+ "msw": "^2.15.0",
40
+ "playwright": "^1.62.1",
41
+ "prettier": "^3.6.2",
42
+ "tsup": "^8.5.1",
43
+ "typescript": "^6.0.3",
44
+ "typescript-eslint": "^8.46.0",
45
+ "vitest": "^4.1.11"
13
46
  },
14
- "scripts": {
15
- "build": "echo 'build placeholder'"
47
+ "engines": {
48
+ "node": ">=20"
16
49
  },
17
- "keywords": ["officeless", "sdk", "nocode"],
18
- "license": "MIT"
19
- }
50
+ "keywords": [
51
+ "officeless",
52
+ "mekari",
53
+ "sdk",
54
+ "automation",
55
+ "workflow"
56
+ ],
57
+ "repository": {
58
+ "type": "git",
59
+ "url": "git@bitbucket.org:jojocoders/officeless-sdk.git"
60
+ },
61
+ "scripts": {
62
+ "build": "tsup",
63
+ "dev": "tsup --watch",
64
+ "type-check": "tsc --noEmit",
65
+ "lint": "eslint .",
66
+ "lint:fix": "eslint . --fix",
67
+ "format": "prettier --write .",
68
+ "format:check": "prettier --check .",
69
+ "test": "vitest run --project node",
70
+ "test:browser": "vitest run --project browser",
71
+ "test:coverage": "vitest run --coverage",
72
+ "test:watch": "vitest"
73
+ }
74
+ }
package/src/client.js DELETED
@@ -1,84 +0,0 @@
1
- import { WorkflowRef } from './workflow.js'
2
- import { TableRef } from './table.js'
3
- import { OfficelessError } from './errors.js'
4
-
5
- export class OfficelessClient {
6
- /**
7
- * @param {object} config
8
- * @param {string} config.baseUrl - Officeless API base URL
9
- * @param {string} [config.apiKey] - optional API key (sent as X-Officeless-Key header)
10
- * @param {string} [config.projectId]
11
- * @param {object} [config.workflows] - map of workflowName → { url, method }
12
- * e.g. { 'employee-list': { url: '/app/wh/abc123', method: 'post' } }
13
- * If provided, used directly. If not, uses baseUrl + /wh/ + name convention.
14
- */
15
- constructor(config = {}) {
16
- if (!config.baseUrl) throw new OfficelessError('baseUrl is required')
17
- this._baseUrl = config.baseUrl.replace(/\/$/, '')
18
- this._apiKey = config.apiKey || null
19
- this._projectId = config.projectId || null
20
- this._workflowMap = config.workflows || {}
21
- }
22
-
23
- /**
24
- * Load config from a plain object (e.g. imported officeless.config.json)
25
- */
26
- static fromConfig(config) {
27
- const c = config?.officeless || config
28
- return new OfficelessClient({
29
- baseUrl: c.base_url || c.baseUrl,
30
- apiKey: c.api_key || c.apiKey,
31
- projectId: c.project_id || c.projectId,
32
- workflows: c.workflows || {},
33
- })
34
- }
35
-
36
- /** Returns a WorkflowRef for the named workflow */
37
- workflow(name) {
38
- return new WorkflowRef(this, name)
39
- }
40
-
41
- /** Returns a TableRef for the named table */
42
- table(name) {
43
- return new TableRef(this, name)
44
- }
45
-
46
- /** Internal: resolve workflow URL and POST to it */
47
- async _callWorkflow(name, payload = {}) {
48
- const entry = this._workflowMap[name]
49
- let url
50
- if (entry && entry.url) {
51
- // URL map mode: url might be relative or absolute
52
- url = entry.url.startsWith('http') ? entry.url : this._baseUrl + entry.url
53
- } else {
54
- // Convention mode: baseUrl/wh/workflow-name
55
- url = `${this._baseUrl}/wh/${name}`
56
- }
57
-
58
- const headers = { 'Content-Type': 'application/json' }
59
- if (this._apiKey) headers['X-Officeless-Key'] = this._apiKey
60
-
61
- const res = await fetch(url, {
62
- method: 'POST',
63
- headers,
64
- body: JSON.stringify(payload),
65
- })
66
-
67
- let body
68
- try {
69
- body = await res.json()
70
- } catch {
71
- throw new OfficelessError(`Failed to parse response from ${name}`, res.status)
72
- }
73
-
74
- if (!res.ok || body?.error === true) {
75
- throw new OfficelessError(
76
- body?.message || `Request to ${name} failed`,
77
- res.status,
78
- body
79
- )
80
- }
81
-
82
- return body?.data !== undefined ? body.data : body
83
- }
84
- }
package/src/errors.js DELETED
@@ -1,8 +0,0 @@
1
- export class OfficelessError extends Error {
2
- constructor(message, statusCode, response) {
3
- super(message)
4
- this.name = 'OfficelessError'
5
- this.statusCode = statusCode
6
- this.response = response
7
- }
8
- }
package/src/index.js DELETED
@@ -1,2 +0,0 @@
1
- export { OfficelessClient } from './client.js'
2
- export { OfficelessError } from './errors.js'
package/src/table.js DELETED
@@ -1,22 +0,0 @@
1
- export class TableRef {
2
- constructor(client, tableName) {
3
- this._client = client
4
- this._tableName = tableName
5
- }
6
-
7
- async list(filters = {}) {
8
- return this._client._callWorkflow(`${this._tableName}-list`, { filters })
9
- }
10
-
11
- async create(data) {
12
- return this._client._callWorkflow(`${this._tableName}-create`, { data })
13
- }
14
-
15
- async update(id, data) {
16
- return this._client._callWorkflow(`${this._tableName}-update`, { id, data })
17
- }
18
-
19
- async delete(id) {
20
- return this._client._callWorkflow(`${this._tableName}-delete`, { id })
21
- }
22
- }
package/src/workflow.js DELETED
@@ -1,10 +0,0 @@
1
- export class WorkflowRef {
2
- constructor(client, name) {
3
- this._client = client
4
- this._name = name
5
- }
6
-
7
- async trigger(payload = {}) {
8
- return this._client._callWorkflow(this._name, payload)
9
- }
10
- }