payload-rest-client's People
payload-rest-client's Issues
Narrow Relationships
Example as reference what payload generates
type User = {
id:string;
email:string;
...
}
type Post = {
id:string;
author: {
relationTo:string;
value: string | User;
}
When getting posts we also receive the relation author as string | User.
But it actually will only be string if we pass fetchParam
{depth:0}
.
I'm not a typescript expert.
Shouldn't it be possible to narrow the relationship types based on the passed parameter for the collections find, findById and for the globals get functions?
Add auth operations to client
As they are currently missing:
Do you plan to add the auth operations to the client?
Can Collection/Global be inferred?
Again, huge fan of this library ... the one thing that annoys me though is I would really like to do api.post.find({})
instead of api.collections.post.find({})
...
maybe this could be managed by following the Payload local API syntax with findGlobal
and updateGlobal
which is how you could infer the base path.
What do you think? I know it's a breaking change, but it doesn't look like you have a ton of users yet ... although that is likely going to change shortly ...
Can `qs` be removed so no dependencies?
Great library here!
Quick question - could qs
be removed and just use URLSearchParams
?
I ask because the qs
library is actually kindof big (like 10kb bundled / gzipped) for things like Edge and Cloudflare Workers where performance actually is impacted a lot by bundle size ... also not to mention client-size browser use as well ...
VSCode will have an squidly red error creating a collection even the property is not required
Typescript should not have an error if the property is not required. updatedAt and createdAt is not required property in the interface.
export interface Registration {
id: string;
name: string;
email: string;
site?: 'site1' | 'site2';
department: string;
contactNumber: string;
tenant?: string | Tenant;
updatedAt: string;
createdAt: string;
}
Example for Authentication
Hello,
it took some time for me to get the authentication part up and running. maybe we can share something like this in the README.md?
a .env for the credentials (because I like to use dotenv :)):
PAYLOAD_API_URL=http://localhost:3000/api
PAYLOAD_API_EMAIL=
PAYLOAD_API_PASSWORD=
client.js for wrapping the creation:
import { createClient } from "payload-rest-client";
export default async () => {
let loginClient = await createClient({
apiUrl: process.env.PAYLOAD_API_URL,
cache: "no-store"
});
let loginResponse = await loginClient.collections.users.login({
email: process.env.PAYLOAD_API_EMAIL,
password: process.env.PAYLOAD_API_PASSWORD
});
return createClient({
apiUrl: process.env.PAYLOAD_API_URL,
cache: "no-store",
debug: true,
headers: {
'Authorization': 'Bearer ' + loginResponse.token
}
})
};
and the using part of code:
import 'dotenv/config'
import clientCreator from './client.js';
(async () => {
let client = await clientCreator();
let speakers = await client.collections.speakers.find({
sort: "name",
locale: "de",
limit: 10,
page: 1,
});
console.log('speakers', speakers);
})();
Should be able to omit required fields when making a draft document
Thank you for the wonderful library, Payload should really have this built-in.
Right now all required fields are required in Typescript as well when using 'create', however in the Admin UI we can make incomplete drafts without all the required fields inputted.
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. ๐๐๐
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google โค๏ธ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.