@tinacms/datalayer 0.0.0-e623534-20250401065516 → 0.0.0-e96d36b-20251210035710

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.js CHANGED
@@ -1,36 +1,13 @@
1
- var __defProp = Object.defineProperty;
2
- var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
3
- var __getOwnPropNames = Object.getOwnPropertyNames;
4
- var __hasOwnProp = Object.prototype.hasOwnProperty;
5
- var __export = (target, all) => {
6
- for (var name in all)
7
- __defProp(target, name, { get: all[name], enumerable: true });
8
- };
9
- var __copyProps = (to, from, except, desc) => {
10
- if (from && typeof from === "object" || typeof from === "function") {
11
- for (let key of __getOwnPropNames(from))
12
- if (!__hasOwnProp.call(to, key) && key !== except)
13
- __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
14
- }
15
- return to;
16
- };
17
- var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
18
-
19
1
  // src/index.ts
20
- var index_exports = {};
21
- __export(index_exports, {
22
- AuditFileSystemBridge: () => import_graphql.AuditFileSystemBridge,
23
- FilesystemBridge: () => import_graphql.FilesystemBridge,
24
- IsomorphicBridge: () => import_graphql.IsomorphicBridge,
25
- LocalBackendAuthProvider: () => LocalBackendAuthProvider,
26
- TinaLevelClient: () => import_graphql.TinaLevelClient,
27
- TinaNodeBackend: () => TinaNodeBackend,
28
- createDatabase: () => import_graphql.createDatabase,
29
- createLocalDatabase: () => import_graphql.createLocalDatabase,
30
- resolve: () => import_graphql.resolve
31
- });
32
- module.exports = __toCommonJS(index_exports);
33
- var import_graphql = require("@tinacms/graphql");
2
+ import {
3
+ FilesystemBridge,
4
+ AuditFileSystemBridge,
5
+ IsomorphicBridge,
6
+ TinaLevelClient,
7
+ resolve,
8
+ createDatabase,
9
+ createLocalDatabase
10
+ } from "@tinacms/graphql";
34
11
 
35
12
  // src/backend/index.ts
36
13
  var LocalBackendAuthProvider = () => ({
@@ -42,10 +19,10 @@ function TinaNodeBackend({
42
19
  options
43
20
  }) {
44
21
  const { initialize, isAuthorized, extraRoutes } = authProvider;
45
- initialize == null ? void 0 : initialize().catch((e) => {
22
+ initialize?.().catch((e) => {
46
23
  console.error(e);
47
24
  });
48
- const basePath = (options == null ? void 0 : options.basePath) ? `/${options.basePath.replace(/^\/?/, "").replace(/\/?$/, "")}/` : "/api/tina/";
25
+ const basePath = options?.basePath ? `/${options.basePath.replace(/^\/?/, "").replace(/\/?$/, "")}/` : "/api/tina/";
49
26
  const opts = {
50
27
  basePath
51
28
  };
@@ -64,16 +41,15 @@ function MakeNodeApiHandler({
64
41
  opts
65
42
  }) {
66
43
  const tinaBackendHandler = async (req, res) => {
67
- var _a, _b, _c, _d;
68
- const path = ((_a = req.url) == null ? void 0 : _a.startsWith("/")) ? req.url.slice(1) : req.url;
69
- const url = new URL(path, `http://${((_b = req.headers) == null ? void 0 : _b.host) || "localhost"}`);
70
- const routes = (_d = (_c = url.pathname) == null ? void 0 : _c.replace(opts.basePath, "")) == null ? void 0 : _d.split("/");
44
+ const path = req.url?.startsWith("/") ? req.url.slice(1) : req.url;
45
+ const url = new URL(path, `http://${req.headers?.host || "localhost"}`);
46
+ const routes = url.pathname?.replace(opts.basePath, "")?.split("/");
71
47
  if (typeof routes === "string") {
72
48
  throw new Error(
73
49
  "Please name your next api route [...routes] not [route]"
74
50
  );
75
51
  }
76
- if (!(routes == null ? void 0 : routes.length)) {
52
+ if (!routes?.length) {
77
53
  console.error(
78
54
  `A request was made to ${opts.basePath} but no route was found`
79
55
  );
@@ -85,7 +61,6 @@ function MakeNodeApiHandler({
85
61
  const allRoutes = {
86
62
  gql: {
87
63
  handler: async (req2, res2, _opts) => {
88
- var _a2;
89
64
  if (req2.method !== "POST") {
90
65
  res2.statusCode = 405;
91
66
  res2.write(
@@ -122,7 +97,7 @@ function MakeNodeApiHandler({
122
97
  query,
123
98
  variables,
124
99
  // @ts-ignore
125
- user: (_a2 = req2 == null ? void 0 : req2.session) == null ? void 0 : _a2.user
100
+ user: req2?.session?.user
126
101
  });
127
102
  res2.statusCode = 200;
128
103
  res2.write(JSON.stringify(result));
@@ -159,8 +134,7 @@ function MakeNodeApiHandler({
159
134
  };
160
135
  return tinaBackendHandler;
161
136
  }
162
- // Annotate the CommonJS export names for ESM import in node:
163
- 0 && (module.exports = {
137
+ export {
164
138
  AuditFileSystemBridge,
165
139
  FilesystemBridge,
166
140
  IsomorphicBridge,
@@ -170,4 +144,4 @@ function MakeNodeApiHandler({
170
144
  createDatabase,
171
145
  createLocalDatabase,
172
146
  resolve
173
- });
147
+ };
package/package.json CHANGED
@@ -1,25 +1,13 @@
1
1
  {
2
2
  "name": "@tinacms/datalayer",
3
- "version": "0.0.0-e623534-20250401065516",
3
+ "type": "module",
4
+ "version": "0.0.0-e96d36b-20251210035710",
4
5
  "main": "dist/index.js",
5
- "module": "dist/index.mjs",
6
- "typings": "dist/index",
6
+ "types": "dist/index.d.ts",
7
7
  "files": [
8
8
  "package.json",
9
9
  "dist"
10
10
  ],
11
- "exports": {
12
- ".": {
13
- "types": "./dist/index.d.ts",
14
- "import": "./dist/index.mjs",
15
- "require": "./dist/index.js"
16
- },
17
- "./dist/*": {
18
- "types": "./dist/*.d.ts",
19
- "import": "./dist/*.mjs",
20
- "require": "./dist/*.js"
21
- }
22
- },
23
11
  "license": "SEE LICENSE IN LICENSE",
24
12
  "buildConfig": {
25
13
  "entryPoints": [
@@ -31,7 +19,7 @@
31
19
  ]
32
20
  },
33
21
  "dependencies": {
34
- "@tinacms/graphql": "0.0.0-e623534-20250401065516"
22
+ "@tinacms/graphql": "0.0.0-e96d36b-20251210035710"
35
23
  },
36
24
  "publishConfig": {
37
25
  "registry": "https://registry.npmjs.org"
@@ -45,17 +33,14 @@
45
33
  "@types/jest": "^27.5.2",
46
34
  "@types/js-yaml": "^3.12.10",
47
35
  "@types/level": "^6.0.3",
48
- "@types/lodash.camelcase": "^4.3.9",
49
- "@types/lodash.upperfirst": "^4.3.9",
50
36
  "@types/node": "^22.13.1",
51
37
  "@types/normalize-path": "^3.0.2",
52
- "@types/yup": "^0.29.14",
53
38
  "jest": "^29.7.0",
54
39
  "jest-diff": "^29.7.0",
55
40
  "jest-file-snapshot": "^0.5.0",
56
41
  "jest-matcher-utils": "^29.7.0",
57
42
  "typescript": "^5.7.3",
58
- "@tinacms/scripts": "1.3.3"
43
+ "@tinacms/scripts": "1.4.2"
59
44
  },
60
45
  "scripts": {
61
46
  "types": "pnpm tsc",
package/dist/index.mjs DELETED
@@ -1,147 +0,0 @@
1
- // src/index.ts
2
- import {
3
- FilesystemBridge,
4
- AuditFileSystemBridge,
5
- IsomorphicBridge,
6
- TinaLevelClient,
7
- resolve,
8
- createDatabase,
9
- createLocalDatabase
10
- } from "@tinacms/graphql";
11
-
12
- // src/backend/index.ts
13
- var LocalBackendAuthProvider = () => ({
14
- isAuthorized: async () => ({ isAuthorized: true })
15
- });
16
- function TinaNodeBackend({
17
- authProvider,
18
- databaseClient,
19
- options
20
- }) {
21
- const { initialize, isAuthorized, extraRoutes } = authProvider;
22
- initialize?.().catch((e) => {
23
- console.error(e);
24
- });
25
- const basePath = options?.basePath ? `/${options.basePath.replace(/^\/?/, "").replace(/\/?$/, "")}/` : "/api/tina/";
26
- const opts = {
27
- basePath
28
- };
29
- const handler = MakeNodeApiHandler({
30
- isAuthorized,
31
- extraRoutes,
32
- databaseClient,
33
- opts
34
- });
35
- return handler;
36
- }
37
- function MakeNodeApiHandler({
38
- isAuthorized,
39
- extraRoutes,
40
- databaseClient,
41
- opts
42
- }) {
43
- const tinaBackendHandler = async (req, res) => {
44
- const path = req.url?.startsWith("/") ? req.url.slice(1) : req.url;
45
- const url = new URL(path, `http://${req.headers?.host || "localhost"}`);
46
- const routes = url.pathname?.replace(opts.basePath, "")?.split("/");
47
- if (typeof routes === "string") {
48
- throw new Error(
49
- "Please name your next api route [...routes] not [route]"
50
- );
51
- }
52
- if (!routes?.length) {
53
- console.error(
54
- `A request was made to ${opts.basePath} but no route was found`
55
- );
56
- res.statusCode = 404;
57
- res.write(JSON.stringify({ error: "not found" }));
58
- res.end();
59
- return;
60
- }
61
- const allRoutes = {
62
- gql: {
63
- handler: async (req2, res2, _opts) => {
64
- if (req2.method !== "POST") {
65
- res2.statusCode = 405;
66
- res2.write(
67
- JSON.stringify({
68
- error: "Method not allowed. Only POST requests are supported by /gql"
69
- })
70
- );
71
- res2.end();
72
- return;
73
- }
74
- if (!req2.body) {
75
- console.error(
76
- "Please make sure that you have a body parser set up for your server and req.body is defined"
77
- );
78
- res2.statusCode = 400;
79
- res2.write(JSON.stringify({ error: "no body" }));
80
- res2.end();
81
- return;
82
- }
83
- if (!req2.body.query) {
84
- res2.statusCode = 400;
85
- res2.write(JSON.stringify({ error: "no query" }));
86
- res2.end();
87
- return;
88
- }
89
- if (!req2.body.variables) {
90
- res2.statusCode = 400;
91
- res2.write(JSON.stringify({ error: "no variables" }));
92
- res2.end();
93
- return;
94
- }
95
- const { query, variables } = req2.body;
96
- const result = await databaseClient.request({
97
- query,
98
- variables,
99
- // @ts-ignore
100
- user: req2?.session?.user
101
- });
102
- res2.statusCode = 200;
103
- res2.write(JSON.stringify(result));
104
- res2.end();
105
- return;
106
- },
107
- secure: true
108
- },
109
- ...extraRoutes || {}
110
- };
111
- const [action] = routes;
112
- const currentRoute = allRoutes[action];
113
- if (!currentRoute) {
114
- res.statusCode = 404;
115
- const errorMessage = `Error: ${action} not found in routes`;
116
- console.error(errorMessage);
117
- res.write(JSON.stringify({ error: errorMessage }));
118
- res.end();
119
- return;
120
- }
121
- const { handler, secure } = currentRoute;
122
- if (secure) {
123
- const isAuth = await isAuthorized(req, res);
124
- if (isAuth.isAuthorized === false) {
125
- res.statusCode = isAuth.errorCode;
126
- res.write(
127
- JSON.stringify({ error: isAuth.errorMessage || "not found" })
128
- );
129
- res.end();
130
- return;
131
- }
132
- }
133
- return handler(req, res, opts);
134
- };
135
- return tinaBackendHandler;
136
- }
137
- export {
138
- AuditFileSystemBridge,
139
- FilesystemBridge,
140
- IsomorphicBridge,
141
- LocalBackendAuthProvider,
142
- TinaLevelClient,
143
- TinaNodeBackend,
144
- createDatabase,
145
- createLocalDatabase,
146
- resolve
147
- };