fimo 0.6.0 → 0.7.0-experimental.1

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.
@@ -37,6 +37,8 @@ describe('syncSchemas', () => {
37
37
  const post = readFileSync(join(scratch, 'src/schemas/Post.ts'), 'utf-8');
38
38
  const postTypes = readFileSync(join(scratch, 'src/schemas/Post.types.ts'), 'utf-8');
39
39
  expect(post).toContain('import { wrapWithSource as wrapAuthorWithSource } from "./Author";');
40
+ expect(post).toContain('isPopulatedEntry(value) ? wrapAuthorWithSource(value) : value');
41
+ expect(post).toContain('function isPopulatedEntry(value: unknown): value is PopulatedEntryRecord');
40
42
  expect(post).toContain('import type { Post, PostInput, PostPopulate, PostResult, PostFields, PostQuery } from "./Post.types";');
41
43
  expect(post).toContain('from "./Post.types";');
42
44
  expect(post).not.toContain('import type { Author } from "./Author";');
@@ -47,9 +49,22 @@ describe('syncSchemas', () => {
47
49
  expect(post).toContain('wrapAuthorWithSource(value)');
48
50
  expect(post).toContain('wrapWithSource(value)');
49
51
  expect(post).toContain('export async function create(payload: PostInput): Promise<Post>');
52
+ expect(post).toContain('export async function getById');
53
+ expect(post).toContain('string | { id: string; locale?: string }');
54
+ expect(post).toContain('typeof value === "string"');
55
+ expect(post).toContain('/entries/Post/');
56
+ expect(post).not.toContain('/v2/entries');
50
57
  expect(post).toContain('return wrapWithSource(data.data);');
58
+ expect(post).toContain('mutationFn : (payload) => create(withMutationLocale(payload, activeLocale))');
59
+ expect(post).toContain('mutationFn : ({ id, ...patch }) => update(id, withMutationLocale(patch, activeLocale))');
60
+ expect(post).toContain('qk.byId(vars.id, { locale: vars.locale ?? activeLocale })');
61
+ expect(post).toContain('{ ...value, locale: value.locale ?? activeLocale }');
51
62
  expect(postTypes).toContain('import type { Author } from "./Author.types";');
52
63
  expect(postTypes).toContain('export interface Post extends WithReferences<PostReferences>');
64
+ expect(postTypes).toContain(' id: string;');
65
+ expect(postTypes).toContain(' entryId: string;');
66
+ expect(postTypes).toContain(' documentId: string;');
67
+ expect(postTypes).toContain(' locale: string;');
53
68
  expect(postTypes).toContain('type FimoReference');
54
69
  expect(postTypes).toContain('author: FimoReference | null;');
55
70
  expect(postTypes).toContain('contributors: FimoReference[];');
@@ -63,7 +78,7 @@ describe('syncSchemas', () => {
63
78
  expect(postTypes).toContain('export type PostResult<');
64
79
  expect(postTypes).not.toContain('PostPopulated');
65
80
  });
66
- it('generates locale-free shared types and locale-sensitive populated target keys', () => {
81
+ it('generates effective-locale shared types and locale-sensitive populated target keys', () => {
67
82
  writeSchema('Homepage', {
68
83
  uid: 'Homepage',
69
84
  name: 'Homepages',
@@ -88,15 +103,15 @@ describe('syncSchemas', () => {
88
103
  const settings = readFileSync(join(scratch, 'src/schemas/Settings.ts'), 'utf-8');
89
104
  const settingsTypes = readFileSync(join(scratch, 'src/schemas/Settings.types.ts'), 'utf-8');
90
105
  const homepageTypes = readFileSync(join(scratch, 'src/schemas/Homepage.types.ts'), 'utf-8');
91
- expect(settingsTypes).not.toContain('locale: string;');
106
+ expect(settingsTypes).toContain('locale: string;');
92
107
  expect(settingsTypes).not.toContain('locale?: string;');
93
108
  expect(homepageTypes).toContain('locale: string;');
94
109
  expect(settings).toContain('const LOCALIZED_CONTENT = false;');
95
110
  expect(settings).toContain('const LOCALIZED_REFERENCE_FIELDS = new Set<string>(["homepage"]);');
96
- expect(settings).not.toContain(' locale: entry.locale,');
111
+ expect(settings).toContain(' locale,');
97
112
  expect(settings).toContain('readLocale(params, LOCALIZED_CONTENT, useQueryLocale(params.locale))');
98
113
  expect(settings.match(/readLocale\(params, LOCALIZED_CONTENT, useQueryLocale\(params\.locale\)\)/g)?.length).toBe(4);
99
- expect(settings.match(/readLocale\(options, false, useQueryLocale\(options\.locale\)\)/g)?.length).toBe(2);
114
+ expect(settings.match(/const locale = useQueryLocale\(options\.locale\);/g)?.length).toBe(2);
100
115
  });
101
116
  it('generates singleton document APIs without collection mutations', () => {
102
117
  writeSchema('Settings', {
@@ -110,7 +125,12 @@ describe('syncSchemas', () => {
110
125
  const settings = readFileSync(join(scratch, 'src/schemas/Settings.ts'), 'utf-8');
111
126
  const settingsTypes = readFileSync(join(scratch, 'src/schemas/Settings.types.ts'), 'utf-8');
112
127
  expect(settings).toContain('fetch(`${base}${withReadOptions(`/documents/Settings`, options)}`');
128
+ expect(settings).toContain('`Settings.id:${id}:${encodeURIComponent(locale)}`');
129
+ expect(settingsTypes).toContain('id: string;');
130
+ expect(settingsTypes).toContain('entryId: string;');
131
+ expect(settingsTypes).toContain('locale?: string;');
113
132
  expect(settings).toContain('export async function update(payload: Partial<SettingsInput>)');
133
+ expect(settings).toContain('mutationFn: (payload) => update(withMutationLocale(payload, activeLocale))');
114
134
  expect(settings).toContain('export function useSuspenseGet');
115
135
  expect(settings).not.toContain('export async function create(');
116
136
  expect(settings).not.toContain('export async function remove(');
@@ -117,14 +117,14 @@ describe('validateSchemas', () => {
117
117
  'Bad.json': {
118
118
  uid: 'Bad',
119
119
  name: 'Bad',
120
- fields: Object.fromEntries(['id', 'documentId', 'slug', 'locale', 'createdAt', 'updatedAt', '__fimo'].map((name) => [
120
+ fields: Object.fromEntries(['id', 'entryId', 'documentId', 'slug', 'locale', 'createdAt', 'updatedAt', '__fimo'].map((name) => [
121
121
  name,
122
122
  { type: 'string' },
123
123
  ])),
124
124
  },
125
125
  });
126
126
  const { errors } = validateSchemas({ cwd });
127
- expect(errors).toHaveLength(7);
127
+ expect(errors).toHaveLength(8);
128
128
  expect(errors.every((err) => err.rule === 'schemas/reserved-field')).toBe(true);
129
129
  });
130
130
  it('rejects unsupported field types', () => {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "fimo",
3
- "version": "0.6.0",
3
+ "version": "0.7.0-experimental.1",
4
4
  "description": "Fimo CLI - create, deploy, and manage Fimo projects",
5
5
  "bin": {
6
6
  "fimo": "dist/cli/index.js"
package/release.json CHANGED
@@ -1,5 +1,5 @@
1
1
  {
2
2
  "source": "npm",
3
- "apiUrl": "https://api.fimo.ai",
4
- "webUrl": "https://fimo.ai"
3
+ "apiUrl": "https://api.staging.fimo.team",
4
+ "webUrl": "https://staging.fimo.team"
5
5
  }
@@ -21,7 +21,7 @@
21
21
  "cmdk": "^1.1.1",
22
22
  "date-fns": "^4.1.0",
23
23
  "embla-carousel-react": "^8.6.0",
24
- "fimo": "0.6.0",
24
+ "fimo": "0.7.0-experimental.1",
25
25
  "input-otp": "^1.4.2",
26
26
  "isbot": "^5",
27
27
  "lucide-react": "^0.577.0",