@diphyx/harlemify 1.0.2 → 1.0.3

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/module.d.mts CHANGED
@@ -1,19 +1,12 @@
1
1
  import * as _nuxt_schema from '@nuxt/schema';
2
- import { MaybeRefOrGetter } from 'vue';
3
2
 
4
- type ApiRequestHeader = MaybeRefOrGetter<Record<string, unknown>>;
5
- type ApiRequestQuery = MaybeRefOrGetter<Record<string, unknown>>;
6
- interface ApiOptions {
7
- url?: string;
8
- headers?: ApiRequestHeader;
9
- query?: ApiRequestQuery;
10
- timeout?: number;
11
- }
3
+ type SharedConfig = {
4
+ api?: {
5
+ url?: string;
6
+ timeout?: number;
7
+ };
8
+ };
12
9
 
13
- interface ModuleOptions {
14
- api?: Pick<ApiOptions, "url" | "timeout">;
15
- }
16
- declare const _default: _nuxt_schema.NuxtModule<ModuleOptions, ModuleOptions, false>;
10
+ declare const _default: _nuxt_schema.NuxtModule<SharedConfig, SharedConfig, false>;
17
11
 
18
12
  export { _default as default };
19
- export type { ModuleOptions };
package/dist/module.d.ts CHANGED
@@ -1,19 +1,12 @@
1
1
  import * as _nuxt_schema from '@nuxt/schema';
2
- import { MaybeRefOrGetter } from 'vue';
3
2
 
4
- type ApiRequestHeader = MaybeRefOrGetter<Record<string, unknown>>;
5
- type ApiRequestQuery = MaybeRefOrGetter<Record<string, unknown>>;
6
- interface ApiOptions {
7
- url?: string;
8
- headers?: ApiRequestHeader;
9
- query?: ApiRequestQuery;
10
- timeout?: number;
11
- }
3
+ type SharedConfig = {
4
+ api?: {
5
+ url?: string;
6
+ timeout?: number;
7
+ };
8
+ };
12
9
 
13
- interface ModuleOptions {
14
- api?: Pick<ApiOptions, "url" | "timeout">;
15
- }
16
- declare const _default: _nuxt_schema.NuxtModule<ModuleOptions, ModuleOptions, false>;
10
+ declare const _default: _nuxt_schema.NuxtModule<SharedConfig, SharedConfig, false>;
17
11
 
18
12
  export { _default as default };
19
- export type { ModuleOptions };
package/dist/module.json CHANGED
@@ -4,7 +4,7 @@
4
4
  "compatibility": {
5
5
  "nuxt": ">=3.0.0 || >=4.0.0"
6
6
  },
7
- "version": "1.0.2",
7
+ "version": "1.0.3",
8
8
  "builder": {
9
9
  "@nuxt/module-builder": "0.8.4",
10
10
  "unbuild": "unknown"
package/dist/module.mjs CHANGED
@@ -1,4 +1,4 @@
1
- import { defineNuxtModule, createResolver, addPlugin, addImportsDir, updateRuntimeConfig } from '@nuxt/kit';
1
+ import { defineNuxtModule, createResolver, addTemplate, addPlugin, addImportsDir } from '@nuxt/kit';
2
2
 
3
3
  const module = defineNuxtModule({
4
4
  meta: {
@@ -11,22 +11,20 @@ const module = defineNuxtModule({
11
11
  defaults: {
12
12
  api: {}
13
13
  },
14
- setup(options, _) {
14
+ setup(options, nuxt) {
15
15
  const { resolve } = createResolver(import.meta.url);
16
+ addTemplate({
17
+ write: true,
18
+ filename: "harlemify.config.mjs",
19
+ getContents() {
20
+ return `export default ${JSON.stringify(options)}`;
21
+ }
22
+ });
16
23
  addPlugin(resolve("./runtime", "plugin"));
17
24
  addImportsDir(resolve("./runtime", "core"));
18
25
  addImportsDir(resolve("./runtime", "composables"));
19
26
  addImportsDir(resolve("./runtime", "utils"));
20
- updateRuntimeConfig({
21
- public: {
22
- harlemify: options
23
- },
24
- options: {
25
- build: {
26
- transpile: [/@harlem\//]
27
- }
28
- }
29
- });
27
+ nuxt.options.build.transpile.push(/@harlem\//);
30
28
  }
31
29
  });
32
30
 
@@ -1,7 +1,7 @@
1
1
  import { defu } from "defu";
2
2
  import { createStore as createHarlemStore } from "@harlem/core";
3
- import { useRuntimeConfig } from "#imports";
4
3
  import { createApi } from "./api.js";
4
+ import { sharedConfig } from "../shared.js";
5
5
  import { resolveSchema } from "../utils/schema.js";
6
6
  import { pluralize } from "../utils/transform.js";
7
7
  import { Endpoint, EndpointStatus, getEndpoint, makeEndpointStatusName, resolveEndpointUrl } from "../utils/endpoint.js";
@@ -23,9 +23,8 @@ export function createStore(entity, schema, endpoints, options) {
23
23
  let apiClient;
24
24
  function api() {
25
25
  if (!apiClient) {
26
- const config = useRuntimeConfig();
27
26
  apiClient = createApi({
28
- ...config.public.harlemify?.api ?? {},
27
+ ...sharedConfig.api ?? {},
29
28
  ...options?.api
30
29
  });
31
30
  }
@@ -3,6 +3,7 @@ export { getMeta, resolveSchema } from "./utils/schema.js";
3
3
  export { createApi, ApiResponseType, ApiErrorSource, ApiError, ApiRequestError, ApiResponseError } from "./core/api.js";
4
4
  export { createStore, StoreMemoryPosition } from "./core/store.js";
5
5
  export { useStoreAlias } from "./composables/use.js";
6
+ export type { SharedConfig } from "./shared.js";
6
7
  export type { EndpointDefinition } from "./utils/endpoint.js";
7
8
  export type { SchemaMeta } from "./utils/schema.js";
8
9
  export type { ApiRequestHeader, ApiRequestQuery, ApiRequestBody, ApiRequestOptions, ApiOptions, EndpointMethodOptions, ApiErrorOptions, } from "./core/api.js";
@@ -1,7 +1,10 @@
1
1
  import { defineNuxtPlugin, useHead } from "#imports";
2
2
  import { createVuePlugin } from "@harlem/core";
3
3
  import { createServerSSRPlugin, createClientSSRPlugin, getBridgingScript } from "@harlem/plugin-ssr";
4
+ import config from "#build/harlemify.config";
5
+ import { sharedConfig } from "./shared.js";
4
6
  export default defineNuxtPlugin((nuxtApp) => {
7
+ sharedConfig.api = config.api;
5
8
  const plugins = [];
6
9
  if (import.meta.server) {
7
10
  plugins.push(createServerSSRPlugin());
@@ -0,0 +1,7 @@
1
+ export type SharedConfig = {
2
+ api?: {
3
+ url?: string;
4
+ timeout?: number;
5
+ };
6
+ };
7
+ export declare const sharedConfig: SharedConfig;
@@ -0,0 +1,3 @@
1
+ export const sharedConfig = {
2
+ api: {}
3
+ };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@diphyx/harlemify",
3
- "version": "1.0.2",
3
+ "version": "1.0.3",
4
4
  "description": "API state management for Nuxt powered by Harlem",
5
5
  "keywords": [
6
6
  "nuxt",